2
\$\begingroup\$

In my game, I am creating two game objects at same position using Instantiate statement. Each generated object has box collider attached.

So I want to detect collision between them so I write following code.

void OnCollisionStay(Collision collisionInfo){
   print("on collision stay");
}

But this statement not called. I generate two object using following code.

BallUtility.AddNormalCommonBall (normalBallPref, Vector3.zero);
BallUtility.AddNormalCommonBall (normalBallPref, Vector3.zero);

I need help in collision detection. I already post question in unity forum but I didn't get any reply from there.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

Collision events will only be detected under specific circumstances.

Each collider can be considered to have these relevant properties:

  1. Is a RigidBody (or RigidBody2D) attached to it's GameObject, if not it is considered Static.
  2. If it has a RigidBody, is it marked Kinematic?
  3. Is the Collider marked Trigger?

The circumstances under which collisions are detected are summarized in this table: enter image description here

Source

\$\endgroup\$
1
  • \$\begingroup\$ Thanks for your suggestion. Now I detect my collision method running. \$\endgroup\$
    – Siddharth
    Feb 1, 2014 at 8:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .