Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

OnTriggerEnter doesn't work

Discussion in 'Scripting' started by JETStudios07, Feb 9, 2021.

  1. JETStudios07

    JETStudios07

    Joined:
    Dec 29, 2020
    Posts:
    22
    Screenshot (36).png Screenshot (37).png Hi. My OnTriggerEnter doesn't work. Can anyone help me?
     
  2. masternully

    masternully

    Joined:
    Dec 22, 2018
    Posts:
    13
    You need to use other.gameObject and then checking the tag.
    Now you are checking the tag of gameObject where this script is placed.
     
  3. JETStudios07

    JETStudios07

    Joined:
    Dec 29, 2020
    Posts:
    22
    I tried it already. It doesn't work
     
  4. masternully

    masternully

    Joined:
    Dec 22, 2018
    Posts:
    13
    Add rigidbody.
     
  5. JETStudios07

    JETStudios07

    Joined:
    Dec 29, 2020
    Posts:
    22
    Doesn't work.
     
  6. masternully

    masternully

    Joined:
    Dec 22, 2018
    Posts:
    13
    Have you added script to gameObject?
     
  7. JETStudios07

    JETStudios07

    Joined:
    Dec 29, 2020
    Posts:
    22
    Yes, I have.
     
  8. masternully

    masternully

    Joined:
    Dec 22, 2018
    Posts:
    13
    Try to change Y scale size. Also you can try to add rigidbody to enemy and player.
    The big amount of problems already solved. You just need to find an issue by yourself.
     
  9. SolitaryDeveloper

    SolitaryDeveloper

    Joined:
    Feb 7, 2021
    Posts:
    8
    Did you perhaps mistype the tag on the enemy? If the tag applied to the enemy gameobject is at all different from the string check (Lowercase, typo,) then it wont work.