Collision Enter one of the objects ?

Hello Again, I’ve been working on collision detecting. So Let me explain;


As following the code;

var collision1 : GameObject;
var collision2 : GameObject;
var collision3 : GameObject;
var collision4 : GameObject;

var collisionFollow1 : Transform;
var collisionFollow2 : Transform;
var collisionFollow3 : Transform;
var collisionFollow4 : Transform;

function Update () {

// I dont know :D


I’m gonna attach theese cubes as gameobjects and, x,y,z,t points as transform.

I don’t know how to detect collision ? i mean;

if (Collision : collision1)


//move forward stuff


if (Collision : collision2)


//move forward stuff



Please help :S

First of all, you shouldn’t add more than one collider to a game object.

  1. Put the colliders into separate objects.

  2. Implement the OnTriggerEnter event on the moving object (maybe a spaceship)

  3. When the event on the ship triggered, you can read the “other” parameter to decide which collider you’ve hit.

so the code will be similar to this:

function OnTriggerEnter(other : Collider) 
    if (other == collision1)
        // do something
    else if  (other == collision2)
        // do another thing