Avoiding Obstacles On The Road

A simple example with my police car and some metal walls in the road. I had trouble with collisions earlier because I forgot to add a Rigidbody to the car. Once I did that it worked, but when the collision occurs I’m still not getting anything printing out.

My code is as follows. Any ideas?

void OnCollisionEnter(Collision collision)
{
print ("Collision detected.");
}

Shouldn’t “Collision detected.” be printed any time there’s a collision with anything? I didn’t put in the tags, but I’m going to skip that for now anyway.

NOTE: Sorry about the sound, I didn’t realize it was recording. I have my fan in the background and my chair is squeaky and you can hear the buttons and mouse clicks. Oops!

1 Like

Privacy & Terms