- Home /
Physics2D.Raycast seems tied to 3D z coordinate?
I set up a simple scene with an orthographic camera and two of the new Unity 4.3 Sprites, a background and a character on top.
When I hit test using Physics2D.Raycast I get the background when I click on the character, so it seems like it is hit testing back to front. I tried adding two new "Sorting Layers", and confirmed that they would indeed control the visual layering of the two sprites, but still using Physics2D.Raycast hit the background first. I did confirm that disabling the background collider allowed the foreground character's collider to be hit.
The fix seems to be to adjust the z coordinate of the background to "push it back" in 3D space. But this must be a either a bug, or I'm misunderstanding something, because there seems little point of using the new Sorting Layer and Order in layer properties of the sprite renderer to manage 2D layering if the Physics2D.Raycast requires a parallel set of layering to be done using 3D z coordinates.
Any thoughts?
Your answer
Follow this Question
Related Questions
Moving pivot point For a 2d sprite 3 Answers
Problem with assigning sprites via raycast 1 Answer
Click/Touch on Different part of sprite detected ? 0 Answers