- Home /
The question is answered, right answer was accepted
Bullet Bug
Every time the bullet hits the player by accident input features stop working. For example the player can't go up or down the ladder freely using the arrow keys, or the player can't buy ammo by pressing the "e" key.
void OnCollisionEnter2D(Collision2D coll)
{
var hit = coll.gameObject;
var hitplayer = hit.transform.tag = "Enemy";
if (hitplayer != null)
{
var Zomhealth = hit.GetComponent<ZombieHealth>();
Debug.Log("hit");
Zomhealth.ZomDamage(damage);
Destroy(gameObject);
}
}
What is this line supposed to do?
var hitplayer = hit.transform.tag = "Enemy";
I tried this if (coll.gameObject.tag == "Player" || coll.gameObject.tag == "Ground") { Physics2D.IgnoreCollision(coll.collider, coll.collider); }
but it didn't work.
void OnCollisionEnter2D(Collision2D coll)
{
var hit = coll.gameObject;
var hitzombie = hit.gameObject.tag = "Enemy";
if (hitzombie != null)
{
if (coll.gameObject.tag == "Player" || coll.gameObject.tag == "Ground")
{
Physics2D.IgnoreCollision(coll.collider, coll.collider);
}
var Zomhealth = hit.GetComponent<ZombieHealth>();
Debug.Log("hit");
Zomhealth.ZomDamage(damage);
Destroy(gameObject);
}
}
I think I found an answer http://www.theappguruz.com/blog/ignore-collision-using-layer-and-tag-concept
Answer by Mansmart10 · Feb 15, 2018 at 02:07 AM
Fixed it b/c of this website http://www.theappguruz.com/blog/ignore-collision-using-layer-and-tag-concept
Follow this Question
Related Questions
iPhoneKeyboard.Open cannot handle multiple entries. Is it a bug? 1 Answer
[BUG?] CrossPlatformInputManager - button keeps down state after new scene is loaded 0 Answers
Input.GetJoystickNames are send me the wrong order of joysticks 1 Answer
First button press don't always register after scene load. 0 Answers
ArgumentException: Input Key named: LeftAlt is unknown 2 Answers