Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved When I place a plane as a child of the player object, can the player stand on the plane?

Discussion in 'Netcode for GameObjects' started by Sushi8819, Oct 27, 2023.

  1. Sushi8819

    Sushi8819

    Joined:
    Oct 20, 2023
    Posts:
    17
    I'm creating a network object prefab where the player is expected to move around on a small plane.
    The player has a Network Animation component, and the plane has a Network Transform component. However, with this setup, when I connect as a client, the transform and animation are not synchronized.
    I'm thinking of attaching all the components to the player and having the plane follow as its child.
    But even with Rigidbody and Collider attached, the player still goes through the plane.
    Could I get some advice, please?"
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,108
    In essence, if you make the plane (floor) a child of the player you're setting it up like this. ;)


    If the plane is not moving, make it a static object with a collider. Any other object with a collider and rigidbody collides with this by default. Make this work with a non-networked player first.

    Then to make the rigidbody player networked, you'd have to use the NetworkRigidbody component on it as well. If you want the plane to move as well, it needs to have a NetworkRigidbody too.

    Note: networked physics, whether server- or client-authoritative, will exhibit rather odd behaviour due to latency (server authoritative) or physics simulation running non-synchronized on each local client (client authoritative). To make network physics "behave" (at least decently) a combination of these two approaches ought to be used, and it will still fall apart the more fast-paced the game is.
     
  3. Sushi8819

    Sushi8819

    Joined:
    Oct 20, 2023
    Posts:
    17