- Home /
detect collisions based on sprite pixel intensity?
Hi, i'm developing a top down 2d game using sprites, and i would like to detect collisions in a more precise manner than just a bounding box or sphere.
for example, lets say i have a 64x64 sprite, of a guy swinging a sword. i could use a collider around the entire sprite (so whenever an object touches any pixel on the sprite, it bounces off), but i would rather be more precise.
i would like to detect when certain pixels within the sprite are contacted by another object, not just the entire sprite. so basically, it would amount to detecting collisions over arbitrary shapes (i would have to create a new shape for each frame of my sprite).
has anyone tried/done anything like this? thanks
Are you wanting polygon collider approximations or pixel perfect collision? You might want to read through this article I found https://timeshapers.com/2014/05/09/pixel-perfect-collision-in-unity-2d/
thanks for the reply. the article looks like its exactly what i need...i guess for rotated textures, it'll take a bit of linear algebra to get the collision point. thanks!
Your answer
Follow this Question
Related Questions
Crop/Mask a Sprite on runtime 0 Answers
How can I enlarge the sprite to avoid the movement of the character when the pivot change? 0 Answers
Changing sprite doesn't put it in the same place? 0 Answers
Collision Killing CPU/FPS/Performance - Suggestions?! 0 Answers
Unity 2D - Game Collision Bug Error 0 Answers