J'ai fait une petite recherche a se propos et j'ai crus comprendre que cette erreur survient quant on fait un if sans condition de retour, or je ne pense pas que cela peu s'appliquer a mon code.
voici le code en question :
Code : Tout sélectionner
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimClient : MonoBehaviour
{
public Animator blue;
public Animator red;
public Animator doctor;
public int attente;
public int NombreClient;
public GameObject ClientBlue;
public GameObject ClientRed;
public GameObject ClientDocteur;
public GameObject Wp;
int MaxClientDifférents = 4;
int pose0 = 0;
int pose1 = 0;
int pose2 = 0;
int pose3 = 0;
int pose4 = 0;
bool wait = true;
void Start()
{
StartCoroutine(Spawn());
}
void Update()
{
if(pose0 != 0 && pose1 == 0 && !wait)
{
StartCoroutine(Trajet1(pose0));
}
if(pose1 !=0 && pose2 == 0 && !wait)
{
StartCoroutine(Trajet2(pose1));
}
if (pose2 != 0 && pose3 == 0 && !wait)
{
StartCoroutine(Trajet3(pose2));
}
if (pose3 !=0 && pose4 == 0 && !wait)
{
StartCoroutine(Trajet4(pose3));
}
}
IEnumerator Spawn()
{
// c'est ici que l'erreur se situe.
wait = true;
pose0 = Random.Range(1, MaxClientDifférents);
if(pose0 == 1) { blue.SetTrigger("blueSpawn"); }
if(pose0 == 2) { red.SetTrigger("redSpaw"); }
if(pose0 == 3) { doctor.SetTrigger("doctorSpawn"); }
wait = false;
StartCoroutine(Minuterie());
}
IEnumerator Trajet1(int id)
{
wait = true;
pose1 = id;
if(id == 1) { blue.SetTrigger("bluePos1"); }
if (id == 2) { red.SetTrigger("redPos1"); }
if (id == 3) { doctor.SetTrigger("doctorPos1"); }
yield return new WaitForSeconds(1);
pose0 = 0;
wait = false;
}
IEnumerator Trajet2(int id)
{
wait = true;
pose2 = id;
if (id == 1) { blue.SetTrigger("bluePos2"); }
if (id == 2) { red.SetTrigger("redPos2"); }
if (id == 3) { doctor.SetTrigger("doctorPos2"); }
yield return new WaitForSeconds(1);
pose1 = 0;
wait = false;
}
IEnumerator Trajet3(int id)
{
wait = true;
pose3 = id;
if (id == 1) { blue.SetTrigger("bluePos3"); }
if (id == 2) { red.SetTrigger("redPos3"); }
if (id == 3) { doctor.SetTrigger("doctorPos3"); }
yield return new WaitForSeconds(1);
pose2 = 0;
wait = false;
}
IEnumerator Trajet4(int id)
{
wait = true;
pose3 = id;
if (id == 1)
{
blue.SetTrigger("bluePos4");
yield return new WaitForSeconds(1);
GameObject clientBlue = Instantiate(ClientBlue, Wp.transform.position, Quaternion.identity);
}
if (id == 2)
{
red.SetTrigger("redPos4");
yield return new WaitForSeconds(1);
GameObject clientRed = Instantiate(ClientRed, Wp.transform.position, Quaternion.identity);
}
if (id == 3)
{
doctor.SetTrigger("doctorPos4");
yield return new WaitForSeconds(1);
GameObject clientDocteur = Instantiate(ClientDocteur, Wp.transform.position, Quaternion.identity);
}
pose3 = 0;
wait = false;
}
IEnumerator Minuterie()
{
yield return new WaitForSeconds(attente);
StartCoroutine(Spawn());
}
}
Si vous avez besoin de plus d’information je serais heureuse de les fournir. J'espère sincèrement que vous pourrez me donner l'astuce qu'il me manque. Bonne soirée