Disable gravity

I have a single sphere and a camera in my scene, and I want the sphere to stay frozen and not fall under gravity.

I created a script for the sphere, have tried the following:

  1. Inside Update(), put
transform.position = Vector3.zero;
  1. Add a rigidbody component to the sphere, and inside Awake(), put
rigidbody.useGravity = false;

Neither worked. I don’t know what else to try, please advise

Would be easiest if you didn’t add the rigidbody component in the first place, then it will be frozen and never fall. Even if you need one for some reason, you can uncheck “use gravity” in the inspector; you don’t need code for that.

–Eric

I’d created a new scene in the 3DPlatformer tutorial, started with a fresh project and it worked without any modifications (like you said)

Thanks

try using Start() next time, it works for me, but if you want its to make it completely static, make it a kinematic rigid body, with isKinematic(rigidbody.isKinematic = true;) otherwise it will not use gravity, but it will still be affected by forces