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
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);
}
}