You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/_docs/core-components/networked-behaviour.md
+1-20Lines changed: 1 addition & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,23 +3,4 @@ title: Networked Behaviour
3
3
permalink: /wiki/networked-behaviour/
4
4
---
5
5
6
-
NetworkedBehaviour is a abstract class that derives from MonoBehaviour, it's the base class all your networked scripts should derive from. It's what provides messaging functionality and much more. Each NetworkedBehaviour will belong to a NetworkedObject, it will be the first parent or first component on the current object that is found.
7
-
8
-
9
-
## Properties
10
-
##### isLocalPlayer
11
-
This returns true if this is the player object of our own client.
12
-
##### isOwner
13
-
This returns true if we own this object.
14
-
##### isOwnedByServer
15
-
Returns true if this object is owned by the server.
16
-
##### isServer
17
-
Returns true if we are a server.
18
-
##### isClient
19
-
Returns true if we are a client.
20
-
#### isHost
21
-
Returns true if we are a host.
22
-
#### NetworkId
23
-
Returns the NetworkId of the NetworkedObject that owns this Behaviour.
24
-
#### OwnerClientId
25
-
Returns the clientId of the Owner of this object
6
+
NetworkedBehaviour is a abstract class that derives from MonoBehaviour, it's the base class all your networked scripts should derive from. It's what provides messaging functionality and much more. Each NetworkedBehaviour will belong to a NetworkedObject, it will be the first parent or first component on the current object that is found.
The connectionData parameter is any custom data of your choice that the client should send to the server. Usually, this should be some sort of ticket, room password or similar that will decide if a connection should be approved or not. The connectionData is specified on the Client side in the NetworkingConfig supplied when connecting. Example:
When you are owner of an object. You can check for ``isOwner`` in any NetworkedBehaviour, similar to how player objects can do ``isLocalPlayer``
18
+
When you are owner of an object. You can check for ``IsOwner`` in any NetworkedBehaviour, similar to how player objects can do ``IsLocalPlayer``
19
19
20
20
## Object destruction
21
21
When a client disconnects. All objects owned by that client will be destroyed. If you don't want that. (Ex. if you want the objects to be dropped), you can remove ownership just before they are destroyed.
To spawn an object. Make sure the object is in the spawnable prefabs array. Then simply instantiate the object. And
7
7
invoke the spawn method on the NetworkedObject component that should be attached to the prefab. This should only be done on the server as the object will automatically replicate on the other clients.
8
8
9
-
Any objects already on the server with NetworkedObject components (static scene objects) will get automatically replicated. When objects are spawned the position and rotation is synced. This means that serialized data gets lost on the clients. It's thus recommended to place serialized data in NetworkedVars.
Any objects already on the server with NetworkedObject components (static scene objects) will get automatically replicated.
17
+
18
+
There are **two** modes that define how scene objects are spawned. The first mode is *PrefabSync*. It can enabled in the NetworkConfig.
19
+
20
+
#### SoftSync
21
+
If PrefabSync is disabled, the MLAPI will use SoftSync. This allows scene objects to be non prefabs and they will not be replaced, thus keeping their serialized data. **This mode is recommended for single project setups**. This is the default since MLAPI 6.
22
+
23
+
#### PrefabSync
24
+
If it's enabled, every scene object has to be a prefab and scene objects are recreated on the client side. This means that serialized data gets lost on the clients. It's thus recommended to place serialized data in NetworkedVars. **This mode is ONLY recommended for Multi project setups**. This was the default before MLAPI 6.
0 commit comments