Unity-Technologies / com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.13k stars 432 forks source link

Add defaultIsKinematic variable to NetworkRigidbody #3036

Open W3ktor opened 1 month ago

W3ktor commented 1 month ago

NetworkRigidbody automatically sets Rigidbody.isKinematic to false on server side.

Please add dafaultIsKinematic variable to NetworkRigidbody so I should decide if I want to init a NetworkObject with kinematic RigidBody on server side network spawn.

My current solution is to create defaultIsKinematic variable in my own Item script (inherited from NetworkBehaviour):

  1. Save original position in Awake if defaultIsKinematic is true (I believe that this would not be necessary if defaultIsKinematic variable would be included in original NetworkRigidbody script)
  2. In OnNetworkSpawn on server side I call IEnumerator to wait for next frame -> I set rigidBody.isKinematic value to defaultIsKinematic value and reset position to original position.
NoelStephensUnity commented 3 weeks ago

Hi @W3ktor,

I am assuming you are using NGO v1.11.0 (or some earlier v1.x.x version)?

The NetworkRigidbodyBase was updated to be more modular and to provide you with "out of the box" ways to handle automatically setting the Kinematic state.

NGO v2.0.0 provides you with this feature.
👍

W3ktor commented 1 week ago

Nice, thanks for the info!