Search Unity

[Solved] OnTriggerEnter not working for only 1 object

Discussion in 'Scripting' started by Deleted User, Nov 15, 2017.

  1. Deleted User

    Deleted User

    Guest

    Edit: Solved. Basically an asset I purchased recently (Ultimate Isometric Toolkit) has a bug, Not sure why it happens but it creates a ghost object for all iso objects and gives them a Unit collider. For some reason, the ghost object was not given a collider.

    In my game, there are various chests with BoxColliders attached to them all with the IsTrigger = true flag set. My player can move onto the chest and the OnTriggerEnter method will be called. Then he can get an item from the chest.
    If the player drops an item, the OnTriggerEnter will not fire when the player walks on that item, even if the player moves away and then back on the item. Dragging the item prefab onto the scene seems to work though.

    Things I have checked:
    - Item BoxCollider Size, Center, and Position. All correct.
    - Moving away from the item and back onto it.
    - Item layer and tag.
    - My player has a RigidBody and can trigger the OnTriggerEnter method just fine when walking on Chest.
    - All I am doing is this:
    Code (CSharp):
    1.             var hits = Physics.OverlapBox(center, halfExtents, orientation, layers);
    where center is the playerPosition, halfExtents is a big enough number, orientation = Quaternion.identity, and layers = Physics.AllLayers.
    - Making the player drop chests inside of items, but still doesn't work!

    I have no idea what could be wrong or even how to go about debugging this.
     
    Last edited by a moderator: Nov 15, 2017