Hi everyone. Is there any way how to make collisions act like in old games ? i.e make both objects stop thier motion instead of pushing each other ? I tryed to achive this by locking and unlocking rigidbody constraints but without sucess.
-Garrom
Hi everyone. Is there any way how to make collisions act like in old games ? i.e make both objects stop thier motion instead of pushing each other ? I tryed to achive this by locking and unlocking rigidbody constraints but without sucess.
-Garrom
When an Object collides try setting it’s velocity to 0?
_
So:
void OnCollisionEnter(Collision coll)
{
if(!coll.gameObject.CompareTag("isGround")) //To be sure we're hitting an obsticle
{
GetComponent<Rigidbody>().velocity = 0.0f; //Stop moving
coll.gameObject.GetComponent<Rigidbody>().velocity = 0.0f; //Stop other Object
}
}
_
Replace the tag function with your preferred method of detecting the ground. If you don’t already have a cached Rigidbody referencing the current one then use GetComponent.
_
Hope this was helpful.