Question by
gamertist · Jan 11, 2016 at 01:18 PM ·
raycastresolutionphysics2d
Raycast doesnt work with any resolution
Hello,
So, i am currently working on a simple game mechanic for my game (players has to click on specific object) however, raycasting is giving me a bit of a problem right now.
Mainly it doesnt work outside of free aspect (meaning if i choose any resolution it just gives me the error of not hitting any collider even if i click on the right object).
This is the code i use for raycast:
if (Input.GetMouseButtonDown(0))
{
RaycastHit2D hit;
hit = Physics2D.Raycast (Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
{
if (hit.collider.gameObject.tag == "GoldCoin") {
Destroy(Clone);
}
}
}
and i have no idea where the problem lies. Maybe i need a different approach?
Comment