Hello, I tried to make it in notifications, the generation of objects will be in the moment the character jumps for the first time, but I just want it to be called once, and not to be done continuously, the problem is that every time That jump is called to the generation of objects and they are created too many by the screen when it should only be called once, how can I limit the call?
public class generadorXY : MonoBehaviour {
public Transform[] spawn;
public float Tmin = 1f;
public float Tmax = 1f;
public Animator animator;
private Animation plataformas;
public GameObject Plataformas;
// Use this for initialization
void Awake(){
animator = GetComponent<Animator> ();
}
void Start () {
NotificationCenter.DefaultCenter ().AddObserver (this, "PersonajeSalta");
}
void PersonajeSalta (){
plataformas = FindObjectOfType<Animation>();
this.InvokeRepeating ("spawnXY", Tmin, Tmax);
}
// Update is called once per frame
void Update () {
}
void spawnXY(){
int spawnIndex = Random.Range (0, spawn.Length);
Instantiate (Plataformas, spawn [spawnIndex].position, spawn[spawnIndex].rotation);
}
}
Thanks for the help, but in its solution something else happens, now it only runs once, that was expected, but only generates an object and does not generate them continuously, the initial error was that every time the character jumped, Lots of objects, thank you very much