need help spawning objects with specific cordinates
Hello,
I'm trying to spawn objects with a specific set of coordinates (0, players Y position, 0).
Basically, i want the objects to spawn on the player's Y position, but spawn on a 0 x position and a 0 z position.
Here is my code for spawning in the objects so far, which only spawns the objects after the player is a certain distance from another object at (0,0,0):
void Update()
{
distance = Vector3.Distance(distanceMesurePointObj.transform.position, transform.position);
Debug.Log(distance + "= DISTANCE");
if(distance > distanceToSpawn)
{
distanceToSpawn = distanceToSpawn + betweenDistance;
Instantiate(coins[Random.Range(0, coins.GetLength(0))], transform.position, Quaternion.identity);
}
Thanks!
Answer by jonasmortensen · May 17, 2017 at 10:12 AM
In your instantiation you write transform.position. Here you can write whatever position you want the coin to instantiate at like new Vector3 (0, transform.position.y, 0)
Your answer
Follow this Question
Related Questions
How can I track positions of instantiated objects 2 Answers
Gameobjects instantiating in the wrong position 0 Answers
Position of empty game objects 1 Answer
Instantiate at touch.position 0 Answers
Cannot set parent for instantiated GameObject. (Exception: Can't destroy Transform component of...) 0 Answers