- Home /
Will PolygonCollider2D detect collision on the z axis?
I am making a birds eye view game with sprites. as my character moves down, his z axis increases, so that objects further down will draw over objects further up. can I use a polygonCollider2D so my character cannot walk through trees and such and he moves down? or should I just use a polygonCollider, my character is currently a sprite object, How does a polygonCollider work on a 2D sprite? Thanks for the help and direction.
Answer by robertbu · Feb 15, 2014 at 09:23 PM
The Collider2D uses a Vector2 rather than a Vector3. So for 2D collision, only the X and Y matter. 'Z' is ignored. So the different depths you are giving sprites will not impact collisions. That means your 'trees' are going to report a collision no matter how far the character is away on the 'z' axis. If you want to consider 'z' as your character moves down with 2D colliders you will have to play some potentially ugly games. How ugly will depend on how you are moving your character. 3D colliders and collisions will work, but you will not get the benefit of tight polygon colliders on sprites.
Thanks for explaining how this works. very helpful
Your answer
Follow this Question
Related Questions
How to detect different parts in sprite? 2 Answers
2D Sprite Collision with 3D Object 1 Answer
Multiple Clickable Areas On Sprite 1 Answer
Implementing 2D Sprite Collisions 1 Answer
Swap object sprites on collision, how? 2 Answers