Hey,
I am using Instatiate() to instantiate new ai cars close to the player when the old ones are too far away from the player. The problem is that each time a new car is created, my game will stop for a couple of frames and then take on again. My script is kind of like this:
var aiCars : GameObjects = new GameObjects[5];
var material : Material;
function SpawnCar()
{
GetSpawnPoints();
var random : Random.Range(0,aiCars.length - 1);
var spawnCar : GameObject = Instantiate(aiCars[random],waypoint.position,Vector3.zero);
var materialrandom : Random.Range(0,material.length - 1);
spawnCar.material = material[materialrandom];
}
as GetSpawnPoint just compares the distance between 200 points, I don’t think that it causes the problem. So is there any way to instantiate a car faster then with Instantiate() ?
I don’t care if the loading time at the beginning is longer, as long as the gameplay is fluent on the iPhone (4S and better)