I am developing 2d platformer and I've faced with a very strange triggers behaviour in Unity. I have made the enemy that can throw objects into main player. So I have made two empty GameObjects with Circle2D colliders on them and attached them into the enemy GameObject. The first trigger ensures that when enemy hand will pass through it, it will spawn an object that will be thrown in future, and the second trigger is responsible for the throw that object into player. The first trigger ensures that when the enemy's hand will pass through it, it will spawn an object that will be thrown in future, and the second trigger is responsible for throwing an object into main player. Every trigger has a Rigidbody2D component attached to it. The hands of the enemy have tags "right hand" and "left hand" and I am checking the in the OnTriggerEnter2D method. This method is calling and I have log messages and this method is detecting that left or right hand are entering trigger. But the problem is in that this method is calling when the hand has already passed through trigger and get out of its bounds. Can anyone help me and explain why this is happening? I have attached a picture where I draw a scheme and described my problem.
\$\begingroup\$
\$\endgroup\$
6
-
\$\begingroup\$ Do any elements have negative scales values? \$\endgroup\$– Kelly ThomasCommented Sep 22, 2014 at 10:07
-
\$\begingroup\$ yes, may be, but I am not sure, because for this moment i have no access to my project. May be the problem happens of this? \$\endgroup\$– bukka.whCommented Sep 22, 2014 at 10:17
-
\$\begingroup\$ There was a problem with earlier versions but it looks like it should be fixed with 4.5 "Fixed child Collider2D position when rotated under negative scale.". It should be easy to confirm by watching the scene view while the game is playing to confirm the collider is actually where it should be. \$\endgroup\$– Kelly ThomasCommented Sep 22, 2014 at 10:43
-
\$\begingroup\$ I checked my project and it appears that my GameObject which marked as a trigger really has negative value on y-scale, but I am working with the latest Unity version 4.5, so this bug must be fixed. May be the problem in something else? \$\endgroup\$– bukka.whCommented Sep 22, 2014 at 14:09
-
\$\begingroup\$ If you watch the scene view while the game is playing do the colliders appear to be in the location you would normally expect? \$\endgroup\$– Kelly ThomasCommented Sep 22, 2014 at 23:28
|
Show 1 more comment