Je suis entrain de m'arracher les cheveux, j'ai besoin de détecter les collisions.
L'avatar du joueur et les ennemis/gentils ont un rigibody et un capsule collider, j'ai du commettre une erreur mais ça fait trois jours que je ne la vois pas. (Pour info, les ennemis/gentils sont des GameObjects avec des "rigidbody" et des "capsule collider" qui ont en enfants un gentil et un ennemi qui évoluent aux cours du jeu.)
J'ai écrit ce code attacher aux ennemis :
Code : Tout sélectionner
void OnCollisionStay(Collision other)
{
Debug.text = "Name = " + other.gameObject.name + "\n" + "Tag = " + other.gameObject.tag;
if (other.gameObject.name == "Soldier" || other.gameObject.tag == "ZombieOrHumain")
{
if(other.transform.GetChild(0).gameObject.activeSelf && other.gameObject != transform.gameObject)
{
if (!zombiesAttack)
{
StartCoroutine("ZombieAttack");
other.gameObject.GetComponent<PointDeVie>().setHP(other.gameObject.GetComponent<PointDeVie>().getHP() - 4);
}
}
}
rb.angularVelocity = Vector3.zero;
rb.velocity = Vector3.zero;
}
void OnCollisionExit(Collision other)
{
if (other.gameObject.name == "Soldier" || other.gameObject.tag == "ZombieOrHumain")
{
if (other.transform.GetChild(0).gameObject.activeSelf && other.gameObject != transform.gameObject)
{
StopCoroutine("ZombieAttack");
zombiesAttack = false;
}
}
}
Et les collisions ne sont pas détecté et on entre jamais dans OnCollisionStay, je ne comprends pas pourquoi...
Pour info, je travaille sur ce jeu :
https://www.youtube.com/watch?v=hyvCoUvXVo4