Just as the title says, Instantiate is only spawning an object at a single position. No matter what values I change. Here’s my code:
// Spawns objects at current location \\
var time : int = 5;
var randomLocationVertical : float = 15;
var randomLocationHorizontal : float = 10;
var randomLocation : Vector3;
var object : GameObject;
var object2 : GameObject;
private var countTime : float = 0;
function Update () {
countTime += Time.deltaTime;
randomLocation = Vector3(Random.Range(randomLocationHorizontal-5, randomLocationHorizontal), Random.Range(randomLocationVertical-5, randomLocationVertical), 0);
if(countTime >= time) {
Debug.Log(transform.position);
Instantiate (object, transform.position + randomLocation , Quaternion.identity);
countTime = 0;
}
}
Did you try printing out randomLocation?
– PiflikYeah, it picks the location fine. I can even use Vector3(100,100,100) and it wont spawn there.
– DoubleEliteDo you have any script on the instanced object that could interfere?
– PiflikNo, sadly I don't.
– DoubleEliteThe script works fine here. There has to be something wrong with the object you're instancing.
– Piflik