Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Created a script to spawn an object at the mouse position on mouse fire but there's an error I don't understand

$
0
0
I assume it's related to the fact that mouse coordinates don't have a Z value and the game world does, but I saw that coming so I set the Z coordinates to 0.0 but it doesn't work. I'm fairly new to programming so I'm sorry if it was something obvious. Here's the error http://gyazo.com/3b6b797bab7f181f35090db6225a1bab Here's my code function Update () { Input.GetKeyDown(KeyCode.Mouse0); { //if(Marker != null) //{ // Marker = null; //} var marker = GameObject.Find("Marker"); var mousePos = Input.mousePosition; mousePos.Z = 0.0; var markerPos = Camera.current.ScreenToWorldPoint(mousePos); Instantiate(marker, markerPos, Quaternion.identity); } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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