Help really appreciated!

I just need to know 2 thing about the network coding!

Lets say:
i’ve already created a movement script and i want to make it multiplayer so that only 1 play will control 1 script not all of them. * i hope you get my point *

and the second thing is that:
How to sync the game

http://unity3d.com/support/documentation/ScriptReference/NetworkView-isMine.html
and
http://unity3d.com/support/documentation/ScriptReference/NetworkView.html

so i just do like
if(NetworkView.isMine) {
ALL THE CODE OF THE FUNCTION
}
??

Or you can do the check in the start method and then enable or disable the script.

so like…
function Start() {
if(NetworkView.isMine) {
enabled = true;
}
else {
enabled = false;
}
}

yep

im not getting the syncing part tho :slight_smile:

and is it ok, to use the network view in singleplayer?

by the way, if another player comes to the server and hes tag is player…
and for each player a script is instantiated to follow the player… will it follow the right one?

You can set the networkview to observe a transform so it will send the transform over the wire.
Or you can create the onserializenetworkview method to send and recieve custom data. You then set the observed property to the script that contains the method.

not entirely sure what you mean by that but probably not. each instance will look in his own scene so you need to make sure you only affect your own objects.

Start()
{
    enabled = NetworkView.isMine;
}
void OnSerializedNetworkView(BitStream stream, NetworkMessageInfo Info) {
	if(stream.isWriting) {
		Vector3 pos = transform.position;
		stream.Serialize(ref pos);
	}
	else {
		Vector3 posRec = Vector3.zero;
		stream.Serialize(ref pos);
		transform.position = posRec;		
	}

could anyone do this into javascript ?

function OnSerializedNetworkView(stream : BitStream, Info : NetworkMessageInfo) {
    if(stream.isWriting) {
        var pos:Vector3 = transform.position;
        stream.Serialize(pos);
    }
    else {
        var posRec:Vector3  = Vector3.zero;
        stream.Serialize(posRec);
        transform.position = posRec;        
    }

must be close to this.

i’ll try it

ok it worked, i’ll try to play with my friend now :slight_smile:

There’s 2 things i noticed, if a client comes in all cameras show his camera and he can walk trough blocks!!!

what should i do! click on the mineral mine link to see what i mean!