- Home /
How to use Physics2D.IgnoreCollision2D in Unity 5 to cancel a trigger
Hello everyone I´m try to use IgnoreCollision2D in the case to evit to player(my player character have to box colliders, one to obstacles and another to check the ground(to know when the character needs to jump))So i need to grouncheck don´t collide to obstacle to doesn´t receive damage. I try to use IgnoreCOllision but appers don´t work
void OnTriggerEnter2D(Collider2D verif){
if(verif.gameObject.name == "Bandeira"){
Application.LoadLevel("Play");
}
else{
Debug.Log("Barreira");
StartCoroutine("DeathParticleDelay");
}
}
public IEnumerator DeathParticleDelay (){
Debug.Log(currentHealth); Physics2D.IgnoreCollision(obsta1.GetComponent() ,chao1.GetComponent());
if(currentHealth >=0){
currentHealth -= 1;
//faz aparecer as particulas
Debug.Log(currentHealth);
Instantiate(deathParticle,PosiPlayer.transform.position,PosiPlayer.transform.rotation);
}
if(currentHealth <0){
Debug.Log(currentHealth);
Instantiate(deathParticle,PosiPlayer.transform.position,PosiPlayer.transform.rotation);
jogador.GetComponent<Renderer>().enabled = false;
PlayerPrefs.SetInt("pontuacao",pontuacao);
if(pontuacao > PlayerPrefs.GetInt("recorde")){
PlayerPrefs.SetInt("recorde",pontuacao);
}
morte = true;
yield return new WaitForSeconds(GameOverDelay* Time.deltaTime);
if(morte == true){
Application.LoadLevel("GameOver");
}
}
}
Thank you so much
Comment
Your answer
Follow this Question
Related Questions
Collider2D/RigidBody2D not working 1 Answer
Collision with renderer.enabled? 0 Answers
Spike Player Die 0 Answers
How can I detect a collision point, but allow player to pass through collider. 1 Answer