2D Toolkit Forum
2D Toolkit => Support => Topic started by: dm on August 23, 2013, 05:29:00 am
-
Hi, i'm want to make a pixel perfect collision detection, so i have question.
I have 2 sprites "Gray" and "White", they collided each other as you can see in attachment.
Can i get pixels for each sprite in intersection? Actually i don't need RGBA, i need only alpha pixels.
Edit: These objects are tk2dSpriteAnimator.
-
There isn't a way to do this out of the box.
You will have to read the texture to get this information -
Work out the position inside the intersection point, work out the UVs for this, and look up into the texture. The problem doing this is that Unity will make a copy of the texture as soon as you read from it, increasing memory overheads significantly.
-
Thank you.
How i can read a texture from current frame of current animation?
-
sprite.CurrentSprite returns the current sprite definition.
You can then extract the positions, uvs, etc from there. You'd have to work out where in the sprite you clicked and find the corresponding UV.
-
Thank you.