Problem with collision in my game.


I have problem with collision detection in my game. I wrote script:

#pragma strict
var myLevel : String;

function OnCollisionEnter (myCollision : Collision) {

 if( == "WoodBarrel"){




I added to my car and when checked - script doesn’t work. New level doesn’t start. I added two box collider to car and woodbarrel.

My woodbarrel looks like:

My car collider:

I took the script from Unity 3D Student - 3d Modelling

How to make collision which work?

Collision’s require a Rigidbody to work, you can apply it to your woodbarrel (Or what ever else you want to set off the level loading) by highlighting it then on the top menu bar clicking “Component → Physics → RigidBody”

I solved my problem with collision. I used playmaker. I made collision:


I added two box collider and rigidbody to my objects (car and barrel) and collision works.