Skip to content

Instantly share code, notes, and snippets.

@pr00thmatic
Created May 29, 2019 21:11
Show Gist options
  • Save pr00thmatic/3f3aeca9a25b6576d81e908c4935ff2b to your computer and use it in GitHub Desktop.
Save pr00thmatic/3f3aeca9a25b6576d81e908c4935ff2b to your computer and use it in GitHub Desktop.
public class MouseRaycastExample : MonoBehaviour {
public void MouseRaycast () {
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Input.GetMouseButtonDown(0) &&
Physics.Raycast(ray, out hit)) {
GameObject created = Instantiate(chispas);
created.transform.position = hit.point;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment