Network - Character Controls

Hi all,

I’m continuing my quest to fully understand Unity’s networking. Now, I’ve got a very simple scene working over a network. Basically, when someone connects, they are spawned a character, in which they can move up, down, left, right and what not. And that character is unique to that user.

The character uses the default third person controllers. Because I want my character to have unique features, I thought I would go ahead and build my own character control script… This is when my network scene started getting ‘weird’. Its hard to explain, but it seemed like we were both controlling the same character, but we could both see where we were in the scene. If everyone moves around at the same time, the character would flash continuously back and forth between each of our positions.

Anyway, I assumed it was because of my character controller I built, and that it needs something unique in it? For a start, it doesn’t use the ‘Character Controller’, nor the ‘Character Motor’, nor the ‘FPSInput Controller’. It just has one simple script (that uses Translates and Slerps) a rigidbody, and a box collider.

What am I missing here?

Here is a snippet of my code:

		//rotate player to face direction arrow
		player.transform.rotation = Quaternion.Slerp(player.transform.rotation, targetRotation, playerRotateSpeed * Time.deltaTime);
        //them move player towards arrow direction
        var translation : float = Input.GetAxis("Vertical") * playerMoveSpeed;
        translation *= Time.deltaTime;


Like I said, I’m trying to get my head around multiplayer… Its always fun to play games with other folks. So I would honestly appreciate any help, or advice. Cheers.

try adding to your script in a function Start()


this way if you added a networkView to the player gameobject the script makes so that you only controls your player. When you make a multiplayer game you should always add this code to scripts that define controls.

When you really whant to understand it read this:

Hope this helps.