com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

Add defaultIsKinematic variable to NetworkRigidbody

Open W3ktor opened this issue 1 year ago • 2 comments

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.

W3ktor avatar Aug 27 '24 17:08 W3ktor

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.
👍

NoelStephensUnity avatar Aug 30 '24 04:08 NoelStephensUnity

Nice, thanks for the info!

W3ktor avatar Sep 15 '24 18:09 W3ktor