Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Sync Rotation of object with server

Discussion in 'Multiplayer' started by wagnva, Sep 3, 2015.

  1. wagnva

    wagnva

    Joined:
    Sep 3, 2015
    Posts:
    1
    Hey unity forum,
    Ive got a small problem. I am currently developing a small 2D tank game. I have started to implement the basic multiplayer using the high level API. At the moment i have my Player prefab with a NetworkTransform Component on it. It all works and the Position for the tanks is the same on all the clients. A tank ofc. also has a barrel. So i now need to make sure that the rotation of the barrel is the same for all the clients. So i put another NetworkTransform Component on the Barrel, a Child object of the Player Tank. But the rotation is never "send to the other clients". I am unsure on how to fix this.

    I unfortunately cannot post any code at the moment, but the rotation of the barrel is calculated to look at the mouseposition and this is inside a if(isLocalPlayer). It works that only the actual players barrel looks at the mouse, but the barrel never rotates for other players.

    I hope it kinda of made sense, and i have no idea on how to solve this. The Settings for the NetworkTransform of the Barrel are the standart ones.
     
  2. SpeakUpGames

    SpeakUpGames

    Joined:
    Nov 25, 2014
    Posts:
    56
    Does the object have a NetworkIdentity? That might be causing it.
    Also check the NetworkTransform's Rotation section and make sure that the Axis isn't set to "None"
     
  3. James_BadAlchemy

    James_BadAlchemy

    Joined:
    Aug 18, 2015
    Posts:
    6
    I've ran into an issue with this before as well. Sometimes, in my personal experience, i cant get unity's networking scripts to work the way that i want. So, i had to make my own scripts. Make sure that the tank prefab has a Network Identity on it. Then look up a guide on how to use Quaternions to grab the rotation of a sprite. I had to do this for an arm on a prefab of a player. The arm followed the mouse, but the client couldn't see the host's arm moving. Hopefully that helps. There are tutorials out there.