Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Enemy GetEnemy()
- {
- if (Input.GetMouseButtonDown(0))
- {
- var ray = Camera.main.ScreenPointToRay(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 1));
- var hit = Physics2D.Raycast(ray.origin, ray.direction);
- if (hit)
- {
- return hit.collider.GetComponent<Enemy>();
- }
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement