Hi guys i need your help;
public GameObject obstacle;
public GameObject player;
public static float maxTime;
public float decrease;
public float increment;
public float timer;
public float timer2;
public float range;
// Start is called before the first frame update
void Start()
{
maxTime = 0.6f;
timer = 0;
timer2 = 0;
}
// Update is called once per frame
void Update()
{
float playerPos = player.transform.position.x;
//Debug.Log(playerPos);
if(timer2 > decrease)
{
if(maxTime > 0.25)
{
maxTime -= increment;
}
}
if(timer>maxTime)
{
GameObject newObstacle = Instantiate(obstacle);
newObstacle.transform.position = new Vector3(0,Random.Range(-10,10),0);
newObstacle.transform.position += new Vector3(playerPos+200,0,0);
timer = 0;
}
timer2 += Time.deltaTime;
timer += Time.deltaTime;
}
how can i stop creating for a moment, example stop for 10 seconds in every 20 seconds.
It would be amazing if you can help me guys i did some research about it but couldn’t make it on my own.
Thank you!!