Create a gist now

Instantly share code, notes, and snippets.

@naspapa /ray
Created Mar 17, 2017

What would you like to do?
void rayGo()
{
//Converting Mouse Pos to 2D (vector2) World Pos
Vector2 rayPos = new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y);
RaycastHit2D hit = Physics2D.Raycast(rayPos, Vector2.zero, 0f);
if (hit)
{
Debug.Log(hit.transform.name);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment