You should read the docs. Rigidbody2D.isKinematic
If this property is set to true then the rigidbody will stop reacting to collisions and applied forces.
Which clearly means, that a kinematic rigidbody is the same as if you didn’t have a rigidbody at all. Although, at Rigidbody.isKinematic, the docs say
If isKinematic is enabled, Forces, collisions or joints will not affect the rigidbody anymore.
which, on the other hand, means, that the rigidbody will not respond to collision by moving away, but still trigger OnTriggerEnter, etc.
The solution?
Set the rigidbody to non-kinematic and use this script.
#pragma strict
private var g : float;
function OnEnable () {
g = rigidbody2D.gravityScale;
rigidbody2D.gravityScale = 0;
}
function Update () {
rigidbody2D.velocity = Vector3.zero;
rigidbody2D.angularVelocity = 0;
}
function OnDisable () {
rigidbody2D.gravityScale = g;
}
With this, it won’t move or rotate, but still trigger collision calls.
Edit: Also, if you want the rigidbody to move again, just disable this script instead of disabling isKinematic.
Edit 2: It seems like gravityScale is applied after any other rigidbody calls, so if the rigidbody2D had gravity, the script wouldn’t stop it’s movement entirely, so I updated the script so that it disables the gravity while it’s enabled.
–David