2
\$\begingroup\$

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 ?

\$\endgroup\$
1
  • \$\begingroup\$ Sounds like an XY question. Why do you want to do this? \$\endgroup\$ Oct 22, 2016 at 1:10

1 Answer 1

1
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\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\$
    – mcelik
    Jul 3, 2015 at 9:02
  • \$\begingroup\$ You need to transform world co-ordinates into pixel co-ordinates. Use Camera.worldToScreenPoint. \$\endgroup\$
    – Greg Quinn
    Jul 4, 2015 at 0:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .