Skip to content

Instantly share code, notes, and snippets.

@jonstvns
Last active August 29, 2015 13:56
Show Gist options
  • Save jonstvns/9044503 to your computer and use it in GitHub Desktop.
Save jonstvns/9044503 to your computer and use it in GitHub Desktop.
void Update()
{
if(Input.GetMouseButtonDown(0))
{
float hitDist = Mathf.Infinity;
Ray ray = Camera.main.ScreenPointToRay(Input.MousePosition);
RaycastHit hit;
if(Physics.RayCast(ray, out hit, hitDist))
{
if(hit.collider.CompareTag("Enemy"))
{
Destroy(hit.collider.gameobject);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment