Hi, I’m making a PayDay Replica, so the question is: How I can instantiate police guys in different positions at the same time?
My Script Is:
I’m using C#…
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
{
[SerializeField]
private GameObject Poliziotto1;
[SerializeField]
private GameObject Macchina;
[SerializeField]
private GameObject Giocatore;
public GameObject spownPointCar;
public GameObject spownPointPolizziotto;
public AudioSource AlarmSource;
public static bool AllarmeAttiva;
public static bool CanSpawn = true;
public bool MacchinaSpawned = false;
public bool PlaySound = false;
void Start ()
{
}
void Update ()
{
if (AllarmeAttiva == true && PlaySound == false)
{
PlaySound = true;
AlarmSource.Play();
}
if (AllarmeAttiva == true && CanSpawn == true)
{
if (MacchinaSpawned == false)
{
MacchinaSpawned = true;
StartCoroutine(SpawnCar());
}
}
}
IEnumerator SpawnCar()
{
Debug.Log("Spowning!");
yield return new WaitForSeconds(8f);
Debug.Log("Spowned!");
GameObject PoliceCar = Instantiate(Macchina, spownPointCar.transform.position, spownPointCar.transform.rotation);
GameObject PoliceMan = Instantiate(Poliziotto1, spownPointPolizziotto.transform.position, spownPointPolizziotto.transform.rotation);
Poliziotto poliziotto = PoliceMan.GetComponent<Poliziotto>();
poliziotto.player = Giocatore.transform;
}
}