Skip to content

Instantly share code, notes, and snippets.

@naspapa
Created March 17, 2017 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naspapa/b0d231b32e24aa2268a5cdfecc361712 to your computer and use it in GitHub Desktop.
Save naspapa/b0d231b32e24aa2268a5cdfecc361712 to your computer and use it in GitHub Desktop.
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