Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

The Basic Thing - Characther Controller over the network

Discussion in 'Multiplayer' started by brust, Jul 13, 2010.

  1. brust

    brust

    Joined:
    Jul 13, 2010
    Posts:
    10
    I have a tank game, multiplayer, and the tank is like that:

    Tank
    -Head
    -LeftWheel
    -RightWheel
    -Body

    Tank : The whole thing, is the only one with a rigidbody, has the Script "CarMovement", because i put 4 wheel coliders on it, 2 on LeftWheel, and 2 on RightWheel, (every WheelCollider, is in an empty object), the tank is the only object with NetworkView, that look to an "TransferScript" atched to the tank.

    Head: has a script "Canon" that moves it, and the camera follow him. No networkview or rigidbody.

    Left and Right Wheel: Has the objects "FrontWheel" and "BackWheel" on each one, and each one with the wheel colidder.

    the script that move is like that:

    function Awake(){
    if (networkview.isMine)
    isMine = true;
    }
    function FixedUpdate(){
    if (isMine){
    //do the movement thing
    }

    the Script that Transfers thing is:

    private var POSITION : Vector3;

    function OnSerialized.. (stream : ... info : ...){
    if (strem.isWriting){
    POSITION = rigidbody.position;
    stream.Serialize(POSITION);
    }
    else{
    stream.Serialize(POSITION);
    rigidbody.position = POSITION;
    }
    }

    basicaly its like that

    but, they aren't sycronized, when i use a simple cube with rigidbody, it work, but with this, its not!
    what should i do?

    ps1 : SYNTAX ERRORS its from my english, in the game its working correctly.
    ps2 : sorry for the bad english, i'm brazillian!!
     
unityunity