Search Unity

[UNET] Problems with syncing Weapon rotation

Discussion in 'UNet' started by sambid123sameer, Jun 28, 2017.

  1. sambid123sameer

    sambid123sameer

    Joined:
    Jun 29, 2016
    Posts:
    11
    Hello Everyone,

    im using this line :- transform.rotation = Quaternion.LookRotation (MyCam.transform.forward, MyCam.transform.up);
    In the Update() Method To rotate my Weapon with the camera's rotation

    Now i want to sync this rotation over the network so other Players can see my Weapon's rotation How do i do this? NetworkTransformChild is not working because the weapon is deep in the childs as its a child object of players hand

    Please Help , TIA
     
  2. Deleted User

    Deleted User

    Guest

    Try making your weapon model a child of your camera. Then add at the root of your prefab a networktransformchild component with as target your camera.

    -Speedex
     
  3. sambid123sameer

    sambid123sameer

    Joined:
    Jun 29, 2016
    Posts:
    11
    Hey thanks for your reply
    I really cant do that because i need my weapon to be parented to the hand so that it moves according to the animation :/
    is there any other way of doing it?
     
  4. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Just send the rotation to the server at the same rate as you send movements. And then RPC it to clients and apply it.
     
  5. sambid123sameer

    sambid123sameer

    Joined:
    Jun 29, 2016
    Posts:
    11
    We can only sync a RigidBody that way , so i have to use either MoveRotation or rb.rotation for rotating , but that snaps the rotation instead or smoothly rotating :/
     
  6. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    What?
    What I mean is when you are sending the player positions to the server. Also send the Weapon rotation.