- Home /
increasing speed and time of spawn game object
Good morning to all, I have ventured a short time ago in the world unity and of the scripting. In the creation of my mobile game I have found a problem. I would want my game object to have a spawn and greater speed increasing in the time on the axis of z. The script that I use to make moving the game object is this:
#pragma strict
var target : Transform ;
var moveSpeed = 3 ;
var rotSpeed = 3 ;
var myTransform : Transform ;
function awake ()
{
myTransform = transform ;
}
function Start () {
target = GameObject.FindWithTag("Player").transform;
}
function Update () {
myTransform.rotation = Quaternion.Slerp (myTransform.rotation, Quaternion.LookRotation (target.position - myTransform.position),rotSpeed * Time.deltaTime);
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime ;
}
While what I use to do spawn them is this:
var hazard : GameObject;
var spawnValues : Vector3;
var hazardCount : int;
var spawnWait : float;
var startWait : float;
var waveWait : float;
function Start () {
SpawnWaves ();
}
function SpawnWaves () {
yield WaitForSeconds (startWait);
while (true)
{
for ( var i : int= 0; i < hazardCount; i++)
{
var spawnPosition : Vector3= new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
var spawnRotation : Quaternion= Quaternion.identity;
Instantiate (hazard, spawnPosition, spawnRotation);
yield WaitForSeconds (spawnWait);
}
yield WaitForSeconds (waveWait);
}
}
How do you advise me of proceeding?
Ps Sorry for my bad english.
You need to look into object pooling - it's explained at the beginning of the link
Skipped the first 1:30 because the guy is just talking about how ill he is, like you care ;)
https://www.youtube.com/watch?v=9-zDOJllPZ8&feature=player_embedded#t=91
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Reset speed after a specified time 0 Answers
speed change in standalone compared to editor? 1 Answer
Reset speed after a specified time 1 Answer