Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer
    
Thanks for your suggestion. Now I detect my collision method running. –  Siddharth Feb 1 at 8:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.