Hey. I have a spritesheet like attached. What I want to do is create a collider that would automatically change it’s size and shape to perfectly fit the frame of the animation that is currently being shown (I am using an animator and .anim file constructed from the separate sprites in the image).
Just in case someone else has the same question: if you were previously using BoxCollider and now switch to PolygonCollider2D, and are using Raycast, here is a working example:
if (Input.GetMouseButton(0))
{
RaycastHit2D hit;
hit = Physics2D.Raycast(new Vector2 (Camera.main.ScreenToWorldPoint (Input.mousePosition).x, Camera.main.ScreenToWorldPoint (Input.mousePosition).y), Vector2.zero, 0);
if (hit.transform == null)
return;
if (hit.transform.gameObject.name != item.name)
return;
print (hit.transform.gameObject.name);
}