Hello Devs,
I am in a position to use a rigidbody collider on a GObject. The rigidbody is just for namesake hence it won’t be using any Gravity and it will be kinematic. Here on this GObject I am using two functions constantly such as
this.transform.rotation = Quaternion.Lerp(this.transform.rotation, Angle, Time.deltaTime/2);
and
one like this -
this.transform.position = new Vector3(idealPos.x,(Target.transform.position.y + 40),idealPos.y);
Is it okay to use in on a rigidbody. I would like to stress again that the purpose of a rigidbody is just for the collider which is used for triggering events.
Thank you,
regards,
Karsnen.
The only physics involved in transform.position is setting the position, so yes, this is perfectly fine.
Pretty much anything in the game can have it’s position set to (x,y,z)–regardless of rigidbodies, colliders, etc.
The big warning about rigid bodies and “external” motion (changing transform.position
yourself) is that it will often break physics. Setting velocity or using AddForce lets physics perform the movement. It can then see two things are going to collide, and bounce them properly.
Just changing position causes the physics to suddenly see overlapping objects. It might blast them apart, or let them overlap, or give a tiny push that looks almost like a proper bounce (so slowly changing position sort-of works on an RB.)
IMHO, isKinematic
is designed for exactly what you’re using it for – making a no-physics-motion/effects object technically count as one, for purposes of joints or causing collisions.