- Home /
Having Problem With Performing Collison with two prefab object.
Hi,... I'm new to unity .This is my first 2D game project.
I'm using two prefab object 1) DropObject 2) HitObject
1)DropObject:
- Added BoxCollider with - IsTrigger -Yes -Size X=5 y=5 Z=10
Added Rigidbody with default and - UseGravity -No - Is Kinematic -No
It is not a moving Object
- This Object is instantiated to 36 Objects
2)HitObject:
Added BoxCollider with
- IsTrigger-Yes -Size X=3 Y=2 Z=10
Added Rigidbody with default and - UseGravity -No - Is Kinematic -Yes
It is a moving object.
Both the DropObject and HitObject have the Z value as 0.
- I have Used Collision Detection functions like OnTriggerEnter() ,OnCollisionEnter(),OnCharacterCollision().But they are not executing (Checked with print() ).
What do I do to Detect Collision between these Objects.
Answer by Extrakun · Mar 11, 2011 at 07:35 AM
You need to attach a rigidboy to one of the cubes. OnCollisionEnter and OnTriggerEnter only fires if one of the colliders is a rigidboy.
You can turn off the gravity in the rigidbody if it is interfering with your logic.
Yeah , I've attached rigidbody component to both objects and both prefab objects are GUITexture Objects....