Multiplayer System HELP,!

Hello, I need help, I’m starting with multiplayer system in unity 3d, in this test I do is move a capsule in both, but I can not make it work, can you help me?, Thanks.

Here the code:
http://www.mediafire.com/?555m5cy0jz47u5u

thanks!

If you look carefully, your N.Instantiated game object is falling slowly…due to this line :

transform.rigidbody.velocity = Vector3.forward * Hori * 100;

Vector3.forward.y equals 0, for your information. By keeping its Y velocity to 0, you prevent his fall…

It won’t either stay on the ground since you set the collider of your capsule to trigger.

Go to Edit > Project Settings > Player. Set Run in background On, it will allow Unity and a stand alone build to run at the same time.

	void OnNetworkInstantiate (NetworkMessageInfo info) {
        networkView.observed = this;
	}

What is the point in doing this? Set the script already in the Inspector, before even play, or give it the rigidbody, it will be faster.

Now, the question worth 100 dollars : why the hell doesn’t Network.Instantiate works ? It seems like it is not buffered, and new clients do not have the previous items…

By the way, I hate C#.

Thanks for your reply, but I still do not solve the problem …

This code:

Hori transform.rigidbody.velocity = Vector3.forward * Hori * 100;

I changed the following:

transform.rigidbody.AddForce (Hori * 300, 0, Input.GetAxis (“Vertical”) * 300);

But I still mark the same error DEBUG:

“Received update for view state id ‘AllocatedID: 1’ but the NetworkView doesn’t exist”

appreciate if you help me solve the problem, thanks.

PD: Turn off gravity.

here an update :

http://www.mediafire.com/?o57l9wzdikxj3ka

i did solve the problem, but i need update the object players of the others players.

See the Unity project in Mediafire…

thanks, and i need help please…

I can not explain

-_-’

That’s my old script.

Oh, well. I have a more recent version that works.

// VARIABLES
public var userPrefab : GameObject;
public var playerList : ArrayList = new ArrayList ();

// EVENTS
function OnServerInitialized () // A USER BECOMES SERVER
{
	var name : String = GenerateRandomName ();
	var nvid : NetworkViewID = Network.AllocateViewID ();
	networkView.RPC ("SpawnUser", RPCMode.AllBuffered, name, nvid);
}

//~ function OnPlayerConnected (player : NetworkPlayer) // DO NOT WORK
function OnConnectedToServer () // A USER CONNECTS TO THE SERVER
{
	var name : String = GenerateRandomName ();
	var nvid : NetworkViewID = Network.AllocateViewID ();
	networkView.RPC ("SpawnUser", RPCMode.AllBuffered, name, nvid);
}

 
function OnPlayerDisconnected (player : NetworkPlayer) // A USER DISCONNECTS FROM SERVER
{
	Debug.Log ("Clean up after player " + player);
	Network.RemoveRPCs (player);
	networkView.RPC ("DeletePlayerData", RPCMode.All, player);
}

function OnDisconnectedFromServer () // A USER STOPS THE CONNECTION
{
	Application.LoadLevel ("Network Ownership Menu");
}

// FUNCTIONS RPC
@RPC
function DeletePlayerData (player : NetworkPlayer)
{
	for (var playerData : PlayerData in playerList)
	{
		if (playerData.player == player)
		{
			if (playerData.object)
				Network.Destroy (playerData.object);
			playerList.Remove (playerData);
		}
	}
}

@RPC
function SpawnUser (name : String, nvid : NetworkViewID, info : NetworkMessageInfo)
{
	var player : NetworkPlayer = info.sender;
	var object : GameObject = GenerateCube (name, nvid);
	var playerData : PlayerData = GeneratePlayerData (player, object);
	if (Network.isServer)
		playerList.Add (playerData);
}

// FUNCTIONS
function GenerateCube (name : String, nvid : NetworkViewID)
{
	var object : GameObject;
	object = Instantiate (userPrefab, transform.position, transform.rotation);
	object.name += name;
	object.networkView.viewID = nvid;
	Debug.Log ("Cube created:" + object.name);
	return object;
}

function GeneratePlayerData (player : NetworkPlayer, object : GameObject)
{
	var newPlayerData : PlayerData = new PlayerData ();
	newPlayerData.player = player;
	newPlayerData.object = object;
	return newPlayerData;
}

function GenerateRandomName ()
{
	return "Cube_" + Random.Range (1,1000);
}

// CLASS
class PlayerData
{
	var player : NetworkPlayer;
	var object : GameObject;
}

Hi, how do this in c#?

JAVASCRIPT:
for (var go : GameObject in FindObjectsOfType(GameObject))
{
go.SendMessage(“OnNetworkLoadedLevel”,
SendMessageOptions.DontRequireReceiver);
}

TO C#:

TO BE…

Then, Convert unity javascript (unityscript) to C#

hi, error with this code traduced by your link:

for (GameObject go in FindObjectsOfType(typeof(GameObject)))
{
go.SendMessage(“OnNetworkLoadedLevel”,
SendMessageOptions.DontRequireReceiver);
}
}

i did solve the problem!, now i need help for stream a Material in

BitStream.Serialize(Matirial)

don’t be right!

aaahhhh, i need a good and complete tutorial pleasee, i am not understand this of network…

You should probably go through the m2h networking zero to hero guide. it’s in the networking forum.