I 'm working on an RTS and want to place a gameobject on the mouseposition. This works, but the object is placed in the wrong location.
The picture below shows a raycast of where my mouse is. But the object (cube, bottom left of the terrain) gets instantiated nowhere near the raycast.
This is the code i'm using to get the position, what am I doing wrong?
toBuild.build(Camera.main.ScreenToWorldPoint(hit.point));

ScreenToWorldPoint? You seem to use a raycast which already gives a result in world space .. - derHugoInstantiate(this, location, Quaternion.identity)This being the gameobject, and location is the location from the raycast - Robin van Breukelen