If isKinematic is enabled, Forces, collisions or joints will not affect the rigidbody anymore.
As explained in rigidbody documentation page, when the property isKinematic
is set to true, collisions won't be checked anymore.
There is something important to understand: the role of the Rigidbody
and the one of the Collider
. Rigidbody
gets all the Physics propeties while Collider
is in charge of giving your object a shape in the physical world. A GameObject that would be composed of a Rigidbody
only will have gravity applied to it (it will fall) but as it doesn't have a physical shape (a Collider) it won't collide with any other object... so if you have a plane under it, it won't stop it in its fall. There are some cases when you want to move a Rigidbody
or rotate it by code, without having the gravity applied or any other forces... this is when you set your Rigidbody
as kinematic.
It depends on what you're trying to achieve. From what I get of your game with in your question, there are NPCs, and collision check and also projectile check. You can use a Rigidbody on every of these things... the restriction is more about "what do you want to do with these?".
- How can I move a kinematic rigidbody so it doesen't go through other kinematic rigidbodies?
Kinematic rigidbodies will never compute collisions. So this is not the path you want to follow. I would suggest you to have a look at most of the Unity tutorials. There, it's explained that you should use AddForce
on Rigidbody
if you want to move it in a direction.
your_rigidbody.AddForce(moveDirection * thrust);
- Spinning
Rigidbody
on projectile impact
It's a classic, your projectile has a Rigidbody
and so does your NPC. So when they collide they both start turning around and spinning like drunk fighters. You don't need to have an active collider on your projectile most of the time. You usually just want to know when a projectile has hit a NPC and then make the projectile disappear and start the rest of the game logic (apply damages, create a visual fx...). Just define your projectile Collider as a trigger and it will not collider with other rigidbodies anymore but -the method OnTriggerEnter
will be called (instead of OnCollisionEnter
) to let you know when another Collider
has entered your trigger. It will prevent your object to spin but still warn you about collisions.
As you seem to have NPCs and want to have them moving in your scene and interact with things... I would suggest you to have a look to NavMeshAgent
feature of Unity. Very well explained here.