Search Unity

Question OntriggerEnter not working

Discussion in 'Physics' started by NewMagic-Studio, Jul 8, 2020.

  1. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    454
    I am using in an enemy object which has a trigger collider

    private void OnTriggerEnter(Collider other)
    {
    Debug.LogError("OnTriggerEnterenemybehav"+ other.gameObject.name);
    }

    It goes against player which has a collider without trigger and rigidbody in one parent object

    I used also OnTriggerEnter method in a script of the parent object and the player

    None of the OnTriggerEnter is triggered even though enemy goes very close the player and the collider radius is big enough and both layers should collide, are not disabled

    Tried also with a kinematic rigidbody in the enemy but doesnt work either

    The enemy has non kinematic rigidbodies as children and the player has rigigbody in parent and in children also a kinematic rigidbody
     
    Last edited: Jul 8, 2020
  2. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    454
    Forgot to mention if i just use the enemy ribidbodies without a trigger collider in the root of the enemy gameobject i get the OnCollisionEnter working, but i wanted not to have collisions just using OnTriggerEnter
    Now trying OnTriggerEnter i have disabled the collisions of the enemies rigidbodies which are not the root