Hello everyone,
I have this scenario. I have a simple prefab which has the following components:
- RigidBody2D - marked as kinematic.
- CapsuleCollider2D.
- PerceptionComponent - a custom component that uses Physics2D.CircleOverlapAll to detect other instances of the prefab in question.
- MovementComponent - a custom component that contains the movement logic.
I read a lot about kinematic rigid bodies and I’m confused. My understanding is that every moving object in my game should either be a dynamic rigid body or kinematic rigid body. This way the objects are registered in the “Physics world” by the Physics engine. Static rigid bodies are optimized by the physics engine.
In my case, I don’t want my prefab to collide with anything. I’m using its collider only in the perception component to do a circle sweep in a given radius.
What is the PROPER way to move the prefab (kinematic rigid body)?
- Should I manipulate transform.position/rotation directly?
- Should I use RigidBody2D.MovePosition/MoveRotation?
- Should I manipulate the rigid body’s velocity?
- Should I use FixedUpdate or Update in my case?
The documentation was ambiguous (to me) when it came down to kinematic bodies. I’m looking for the best way to move a kinematic body. What are the differences between the different approaches in terms of the Physics Engine?
