Hello everyone, my question is simple, I have this script that moves blocks at a certain speed and destroys them as you can see in the script (and I have other script that spawns this blocks) and I want that this variable:
public float movementSpeed = 10f;
to be more every X seconds, for example, every 10 seconds add 1 to the variable, so the speed of the objects is 11, and every other 10 seconds add another 1 to the variable so it is 12, and so on, but if I add a Coroutine and new objects are spawned they always have 10 in the variable, I want it to be like a “universal” variable so the new objects spawned have the “new” speed…
I have no idea how to do it maybe it’s very simple but if anyone could help me it would be appreciated. thanks and sorry for bad english, here’s the script:
using UnityEngine;
using System.Collections;
public class Block : MonoBehaviour {
public float movementSpeed = 10f;
void Start ()
{
}
// Update is called once per frame
void Update () {
transform.Translate(Vector3.down * movementSpeed * Time.deltaTime);
if (transform.position.y < -2f)
{
Destroy(gameObject);
}
}
}