Search Unity

Triggers not always registering other triggers (when they are moving)

Discussion in 'Physics' started by DAPPSD, Jan 3, 2019.

  1. DAPPSD

    DAPPSD

    Joined:
    Apr 26, 2018
    Posts:
    47
    - I have few boxes and a single sphere, all have colliders set as trigger, the sphere follows the mouse position
    - When the sphere enters the trigger of one of the boxes, the 'OnTriggerEnter' of the sphere prints the name of the collided object (the name of the cube)
    - most of the time the 'OnTriggerEnter' of the sphere works as intended but some of the times it completly ignores the triggers of the boxes and don't call the 'OnTriggerEnter' of the sphere, it usually happens when the sphere moves kinda fast (not really fast tho)
    - All the triggers has rigidbodies with locked rotations and some position axis locked as well, also their 'Collision detection' is set to 'Continuous', and the boxes move with rigidbody.AddForce... Also the sphere is set as kinematic
    - I tried moving the sphere using different methods like: transform.position = vector3.MoveTowards, or rigidbody.MovePosition, or transform.Translate but non of these methods seems to have any effect on the trigger of the sphere and non of these different ways have prevented the trigger from sometimes skipping some of the boxes triggers...

    And after some help attempts from reddit I also tried:
    - I tried to handle the movement of the boxes as well as the sphere with transform.position and got no improvement in the situation, it's still skipping triggers when moving fast...
    - Then I changed the boxes back to rigidbody.AddForce and tried to move the sphere with rigidbody.AddForce as well, and saw very little improvement but not so much that'd be worth switching to movement based on physics rather than position.. (I feel like in my case moving the sphere based on physics would bring more troubles along the way..)
    - Instead of OnTriggerEnter I tried using RayCast in the Update method of the sphere to detect for hits in the Vector3.forward direction of the sphere and the situation got even worse, and some triggers still aren't being detected when moving fast...

    I'd love to get some help..., Thanks in advance! :)