Answer the question
In order to leave comments, you need to log in
How to change the speed of an action?
I wanted to make such a logic that with each set of points 10, 20 .... (for example) the speed of respawning of objects increases.
A simple solution is needed. I'm new to this business)
sco is the number of Spawn points
is the respawn of the enemy, it happens constantly
Second this is just the time that should shrink to cycle faster
public class spauncars : MonoBehaviour{
public GameObject[] cars;
public static float second = 2.8f;
private float[] position = { -1.47f, -0.51f, 0.58f, 1.61f };
private score SCORE;
private int sco;
private void Start(){
SCORE = GameObject.Find("deletepanel").GetComponent<score>();
sco = SCORE.count;
StartCoroutine(spawn());
}
IEnumerator spawn()
{
if (sco % 2 == 0)
{
second -= 0.6f;
}
while (true)
{
{
Instantiate(
cars[Random.Range(0, cars.Length)],
new Vector3(position[Random.Range(0, 4)], 7f, 0),
Quaternion.identity
);
}
yield return new WaitForSeconds(second);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question