|
I just started learning unity and trying to implement tetris. But I encountered the following issue: As you can see at the screenshot I have Z object. Z is an empty object without any components. It consist of 4 cubes with enabled Box Collider as children objects. Level is an empty object too. Bottom/Top/Right/Left Borders are Cubes How to detect collisions of Z with Level object? I tried to add OnCollisionEnter to child cubes but it is not called.
(comments are locked)
|
|
The thing you want to have an OnCollisionEnter on needs to have a rigidbody attached - you can set it to isKinematic = true to it doesn't move with physics. I tried to add a rigitbody to Z object and set isKinematic = true but OnCollisionEnter still was not called for Z object as well for child cubes.
Jul 14 '12 at 12:24 PM
Gennadiy
From the screen shot it appears your colliders are set to isTrigger - if that is the case you only get OnTriggerXXX functions not the OnCollisionXXX
Jul 14 '12 at 02:24 PM
whydoidoit
I was experimenting and forgot to uncheck isTrigger but I tried both cases and still without success.
Jul 14 '12 at 03:22 PM
Gennadiy
(comments are locked)
|
|
How I resolved this issue. I set isTrigger = true for box colliders of Left/Right/Bottom/Top borders. Added a rigidbody component to Z object. Set isKinematic=true for the rigitbody. Added OnTriggerEnter handler to Z object.
(comments are locked)
|

