How to check for a collision?

So i have a game i am working on, and i want to be able to print something to the console when a Bullet hits a box, both Rigid bodies.

What commands are there?,

Hi,

i think

Should do it ?!

You are looking for the Collider Object Component:

Thanks for the replys, But i am slightly confused, Could somebody give me an example of using the OnCollisionEnter in a if/else statment?

I think you have to attach a script to your bullet gameobject

void OnCollisionEnter(Collision collision) {

Debug.Log(“Hit”);
}

Dosent work, i get

“expecting ), found ‘:’”
“;’ expected. Insert a semicolon at the end.” even though there is one
and " Unexpected token: )."

And your script looks like ?

do you write in js or in c# `?

java

function Update ()
{

void OnCollisionEnter(Collision:collision)
{
Debug.Log(“Hit”);
}

}

is my code

So then the script should look like

function OnCollisionEnter(collision : Collision ) {

Debug.Log(“Hit”);
}

Then i get the error “expecting (, found ‘OnCollisionEnter’.”

ah, you should definitely read the manual!

the right code

function Update ()
{

}

function OnCollisionEnter(Collision:collision)
{
Debug.Log(“Hit”);
}

Still not working :stuck_out_tongue:

should work

Definatly?, it keeps telling mt it needs a ‘(’ but when i put it in it then tells me that the ‘(’ is unexpected

function Update ()
{

function OnCollisionEnter(collision : Collision) {

Debug.Log(“Hit”);
}

}

hmm :slight_smile: can you post your code again ?

fixed it

function Update ()
{

}

function OnCollisionEnter(collision : Collision)
{
Debug.Log(“Hit”);

}

The ‘{’ was in the wrong place =]

So, than now nothings stands in your way to create the next epic game :slight_smile:

yup =]