Skip to content

Commit

Permalink
fix: dead enemy won't collide with bullets and will stay on scene
Browse files Browse the repository at this point in the history
  • Loading branch information
yy4382 committed Mar 28, 2024
1 parent 8571347 commit ee50802
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Assets/Scripts/BulletBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void OnCollisionEnter2D(Collision2D other)
{
Debug.Log("Enemy hit by bullet");
Kill(other);
Destroy(other.gameObject);
// Destroy(other.gameObject);
return;
}

Expand Down
3 changes: 1 addition & 2 deletions Assets/Scripts/MoveBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ public void Die()
{
animator.SetTrigger("Die");
var collider = GetComponent<Collider2D>();
LayerMask layerMask = 1 << LayerMask.NameToLayer("Ground") | 1 << LayerMask.NameToLayer("Wall");
collider.includeLayers = layerMask;
collider.excludeLayers |= 1 << LayerMask.NameToLayer("Bullet");
rigidBody.velocity = new Vector2(0, rigidBody.velocity.y);
}
}
1 change: 0 additions & 1 deletion Assets/Scripts/SpikeBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ void OnCollisionEnter2D(Collision2D other)
if (other.gameObject.CompareTag("Enemy"))
{
Kill(other);
Destroy(other.gameObject);
return;
}

Expand Down
1 change: 0 additions & 1 deletion Assets/Scripts/SpikeBlockBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ void OnCollisionEnter2D(Collision2D other)
if (other.gameObject.CompareTag("Enemy"))
{
Kill(other);
Destroy(other.gameObject);
return;
}

Expand Down

0 comments on commit ee50802

Please sign in to comment.