I don't want rigid move while collision goes on

That’s the problem: I don’t want movement of rigidbody while colliding with other rigids. Not all rigids, but tagged with certain tag. It happens when rigid A stays and rigid B moves to A and hits that. If rigid B tagged “1”, A should stay like stone. Else, hit should be applied. I’ve tried to do next:

function OnCollisionEnter(e:Collision){
rigidbody.velocity -= e.relativeVelocity;
}

Or “OnCollisionStay” with same code. But it does not work well: rigid A starts a quake. Help me please.

On your Object then on your Rigidbody Component there are Constraints - Set the values to which you want. And you don’t need that script any more.

  • Felipe

you could change the rigidbody isKinematic value.

http://unity3d.com/support/documentation/ScriptReference/Rigidbody-isKinematic.html

In your collision function , check the tag of the object, if you don’t want to move it, then apply : rigidbody.isKinematic = true;

then return the state to false on collision exit. Play with this and see if it works for you.

e.g. :

function OnCollisionEnter (otherCol : Collision)
{	
	if (otherCol.rigidbody.tag == "Rock")
	{
		otherCol.rigidbody.isKinematic = true;
	}
}


function OnCollisionExit (otherCol : Collision)
{
	otherCol.rigidbody.isKinematic = false;
}