I have a prefab and I use Circlecollider2D for physics operations. I want to detect the color of the contact position of the collided objects ? Is is possible by using Unity's collider classes ?
1 Answer
\$\begingroup\$
\$\endgroup\$
2
Take a Look at Texture2D.GetPixel
You can find the contact point on the collider and then map that to the specific point on the texture.
-
\$\begingroup\$ Correct me if I am wrong but I think the contact point gives me world coordinates of collision. But I need texture coordinates for GetPixel(x, y) function ? \$\endgroup\$– mcelikCommented Jul 3, 2015 at 9:02
-
\$\begingroup\$ You need to transform world co-ordinates into pixel co-ordinates. Use Camera.worldToScreenPoint. \$\endgroup\$ Commented Jul 4, 2015 at 0:11