Quantcast
Channel: Answers by "Flynn"
Viewing all articles
Browse latest Browse all 59

Answer by Flynn

$
0
0
You will need to encapsulate your integers in a Vector3, like this: if(Input.GetMouseButtonDown(0) && collider.Raycast(Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, (Screen.height / 2, 0)), hit, Mathf.Infinity)) { } Note that I have inserted new Vector3() around your three integers, that will cause them all to be a part of a newly created Vector3 object, which ScreenPointToRay can use : D EDIT: As Kat0r has pointed out,
Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));//C# version Camera.main.ViewportPointToRay(new Vector3(0.5, 0.5, 0.0));//JS version Is another (slightly faster) way to get the center of the screen

Viewing all articles
Browse latest Browse all 59

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>