- Home /
Detect collision by color?
Hello. I'm making 2d iOS game and have question about collision. The game is made in a minimalist style, and consists of only two colors (for example, black and white). The player controls a small square that can only move in the white zone. This zone can have a very complex shape (see picture). My task is to determine whether the player is in the white area or not.
That's what I came up with:
Method 1 (legacy)
Add PolygonCollider2D around white area and Rigidbody2D to player. If invoked OnCollisionLeave2D(), then player left white area.
Method 2 (my own)
Detect the following in the direction of the player color (i think i can use Texture2D.ReadPixels()), and if color is black, then player left white area.
I would like to know whether it is possible to use the second method or not, and if so, will it be more performance friendly that first.
Thank you in advance for your reply and sorry for bad english.
Your answer
Follow this Question
Related Questions
Trigger a color change via collide 1 Answer
Sprite Color Change upon collision 1 Answer
Object collision change colour 2 Answers
Make a quad glow on collision? 1 Answer
How to change colors in turn? 1 Answer