My bullet damage myself~ help pls! thank!

Options

My bullet C#

private void OnCollisionEnter(Collision collision)

  {

    if (collision.collider.tag == "Player")

    {

      PlayerData pd = collision.gameObject.GetComponent<PlayerData>();

      pd.TakeDamage(DamageAmount);

 }

 }


I want to make bullet only damage on hit other player, but collision self don't .

(my bullet is a big fire ball, Shoot out from the body)

but my tag is same as other "Player"

cannot find answer... is someone can teach me?

THANKS!

Comments

  • M4TT
    Options
    Hello
    It could be because the spawner location of the bullet is inside your player, so the bullet spawn and collides instantly with yourself ?

    Instead of check if there is collision on your bullet you can try the other way by checking if there is collision on your player prefab