How to make physics collisions act like in old games (NES, SNES especially)
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
Comment
Answer by IMemeManI · Jan 17, 2018 at 02:44 PM
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.
If you don't want to use Collision detection, try raycasting.