enemy and player do not collide
Hello, I want to make my enemy kill my player on collision. Unfortunately I do not see where I am going wrong. please help me if you can! :) many thanks in advance.
player script
void OnCollisionEnter2D(Collision2D target)
{
if(target.gameObject.tag == "Ground" || target.gameObject.tag == "Pipe")
{
if (isAlive)
{
isAlive = false;
anim.SetTrigger("Bird Died");
audioSource.PlayOneShot(diedClip);
GameplayController.instance.PlayerDiedShowScore(score);
}
}
}
This work just fine, if my player hits the ground or a pipe he dies. but i try doing this
if(target.gameObject.tag == "Ground" || target.gameObject.tag == "Pipe" || target.gameObject.tag == "Enemy")
and this does not work, So i also tried adding an else if just for the enemy (because i wasnt sure if i am allowed to write more than a single || in an argument.) - that also did not work
Worth Noting
I also have my Player Colliding with my enemy in the 2d physics settings.
The Player and the Enemy are on the
same sorting layer
Unsure what is causing this, but just to be sure:
Are you sure that the tag is spelled correctly?
Are you sure that you do not have the enemy set to trigger? (Which would cause a OnTriggerEnter2D ins$$anonymous$$d of a OnCollisionEnter2D)
Your answer

Follow this Question
Related Questions
How to generate a raycast on keydown and store what it hits as a variable 0 Answers
Collider gets sometimes stuck at wall 0 Answers
I need help with making a game over when an object interacts with a wall? 0 Answers
Character hits invisible ghost collision when jumping against objects while pushing against them 0 Answers