Timeline for Unity: Restrict movement inside a gameobject (2D)
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 4, 2015 at 18:32 | answer | added | starikcetin | timeline score: 0 | |
Oct 4, 2015 at 4:26 | comment | added | ketura | The thing about sprites is that they are inherently rectangular--they are literally a Rect on a Texture2D. You're going to have to analyze your sprite for opacity, like DMGreg mentioned. Check each pixel, if it has alpha of less than 255, create a 1-pixel large collider. This will have performance issues with high-res maps. We'd probably need more context on why you need this method to suggest other avenues of action. | |
Jun 5, 2015 at 16:49 | answer | added | greenland | timeline score: 1 | |
Jun 3, 2015 at 22:55 | comment | added | Jeff Burghess | One of the problems with my first solution was that it only worked for rectangles -- I want it to work for any shape of the sprite | |
Jun 3, 2015 at 21:48 | comment | added | DMGregory♦ | Is your containing object always a box (ie. a rectangle) or do you want to support other shapes based on 2D colliders (circle, polygon), or based on the pixel opacity values in the sprite? | |
Jun 3, 2015 at 21:22 | history | asked | Jeff Burghess | CC BY-SA 3.0 |