well i need help if you can answer i will be grateful. my object is falling, and when it arrives at some point it reappears somewhere else random, I’m using this code, all right.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class SpawnController : MonoBehaviour {
public float maxHeight;
public float minHeight;
public float rateSpawn;
private float currentRateSpawn;
public GameObject objectPrefab; .
public int maxSpawnObjects;
private List<GameObject> objectsList = new List<GameObject>();
// Use this for initialization
void Start () {
for (int i = 0; i < maxSpawnObjects; i++) {
objectsList.Add(Instantiate(objectPrefab));
objectsList[i].SetActive(false);
}
}
// Update is called once per frame
void Update () {
currentRateSpawn += Time.deltaTime;
if (currentRateSpawn >= rateSpawn) {
currentRateSpawn = 0;
Spawn();
}
}
private void Spawn() {
float randHeight = Random.RandomRange(maxHeight, minHeight);
for (int i = 0; i < maxSpawnObjects; i++) {
if (objectsList[i].activeSelf == false) { .
objectsList[i].transform.position = new Vector3(transform.position.x, randHeight, 0);
objectsList[i].SetActive(true);
break;
}
}
}
}
but I need to change this script.
when i use my last animation i want to call a script call the random reappearance of my object, just that line of script.