bob maximus
bob maximus

Reputation: 39

the code seems to skip this code for my collider, how do I make it work?

I have visited many forums for this problem and I have searched lots of tutorials for this issue. Here's my code :

private void OnTriggerEnter(Collider collision)
{
    GameObject collisionGameObject = collision.gameObject;

    if (collisionGameObject.name == "playerBullet")
    {
        Debug.Log("damage taken");
        TakeDamage(40);
    }
}

I should be doing everything right, what went wrong?

Upvotes: 0

Views: 35

Answers (1)

CorrieJanse
CorrieJanse

Reputation: 2598

Make sure of the following things:

  1. Your GameObject with the script must have a collider.
  2. Your GameObject with the script must be set to Collider and not Trigger
  3. Your GameObject with the script must have a RigidBody
  4. Your Bullet must have a collider.
  5. Your Bullet must have a collider that is not a trigger.

Upvotes: 1

Related Questions