Question by
bat_hol · Dec 10, 2019 at 09:41 AM ·
2dplatformertriggersstudent
OnTriggerExit2D called repeatedly
Hi, for a student project i'm making a 2D platformer. to know if the player is grounded or not i created as child an empty gameobject with just a capsuleCollider2D and this script :
private void OnTriggerStay2D(Collider2D collision)
{
parent.GetComponent<EnemyController>().grounded = true;
//parent.GetComponent<EnemyController>().Atterrissage();
animator.SetBool("Grounded", true);
}
private void OnTriggerExit2D(Collider2D collision)
{
Debug.Log("exitTrigger");
StartCoroutine(unground());
}
IEnumerator unground()
{
yield return new WaitForSeconds(0.1f);
parent.GetComponent<EnemyController>().grounded = false;
animator.SetBool("Grounded", false);
}
And the probleme is that the OnTriggerExit2D is called everytime even if the player isn't moving.
I take any advice and help thanks..
Comment
Your answer
Follow this Question
Related Questions
Platformer 2D 1 Answer
2D RigidBody slightly penetrates objects causing a bounce effect. 3 Answers
Having a couple of problems regarding 2D Movement. 1 Answer
Best way to generate meshes based on algebraic functions? 0 Answers
Gradient on Platform 0 Answers