I am tying to put together a 2D game project, part of which requires me to sense the color of a sprite, when it makes contact with the player-controlled object. However, some of the objects will have multiple colors, such as the object in the included picture.
This sprite can be coming towards the player’s object, from any angle or position onscreen. It will ALSO be rotating as it is approaching the player. What I would like to know is if there is a good way to detect what side it collides with the player on (whether the red, green, or blue side is touching the player’s piece when they make contact). I have already looked into using three different Edge Colliders (one for each third section) but soon found out that there would be no way to differentiate them. I am currently trying a solution that involves me calculating the angle that each colors has within the circle, the circle’s starting rotation, angle in respect to the player, and then the angle when colliding, and trying to figure out what the color must be based on math and angles. Also, to be clear, the player’s controlled object does NOT change position onscreen, it is always in the exact center. However, is there another solution that might work to this, that is perhaps more simple and elegant? Thank you in advance for all of your help!