Question by
bommba · Oct 25, 2015 at 06:11 PM ·
c#gameobjectinstantiatespawningglobal
How can I instantiate a object on the world coordinates
Hey does anybody knwo how I can instantiate a object on the world coordinates (global) instead of the local coordinates of a camera?
For example: I have the camera and the object should be spawn on X-Axis 10 and Y-Axis 5. The camera is on x: 2 and y: 3. Now when I spawn a Object from the camera it spawns on x: 12 and y: 8. But I want to spawn a object on x:10 and y:5.
Comment
Please post your code so we can see what the issue might be.
Answer by Michael_-01-_ · Oct 25, 2015 at 09:13 PM
You could first declare a vector3 for example called Pos like this...`
`
Vector3 Pos;
public GameObject ObjectToSpawn;
void Start()
{
Pos = new Vector3(10, 5, 0);
Instantiate( ObjectToSpawn, Pos, Camera.Main.transform.rotation);
}