Search Unity

Question Unexpectedly exiting Collider that is moved along with the player

Discussion in 'Physics' started by CortiWins, Nov 5, 2023.

  1. CortiWins

    CortiWins

    Joined:
    Sep 24, 2018
    Posts:
    150
    Here's my problem and the thing i do not understand.

    I got an elevator with the following parts ( see screenshot )
    • Platform - Empty object, with a Scale of 1.0, which is moved by the elevator script
    • Platform.Physical - the visible mesh and the ground collider
    • Platform.Attach - trigger-collider that makes the player a child of itself
    • The player is a Unity.CharacterController moved in Update
    • The elevator script moves the Platform in Update

    I got debug lines showing, that the player character while being a child of Platform.Attached is moved by the exact amount that the whole platform is moved.
    This works flawlessly while moving upwards, but moving downwards, the player OnTriggerExits the attach-collider.
    The player is a CHILD of the collider and has ZERO movement in local space relative to the collider, they are both moved by the parent of the collider. Yet the OnTriggerExit happens.
    upload_2023-11-5_9-9-32.png
     
  2. CortiWins

    CortiWins

    Joined:
    Sep 24, 2018
    Posts:
    150
    Update: The coordinates logged after moving both objects in Update and then in the next physics

    a) same coordinates -> TriggerStay
    b) same coordinates -> Trigger Exit

    what the magic?^^
    upload_2023-11-5_11-50-37.png
    So obviously moving them both as parent and child works fine, the distance between them stays the same, yet one time, the collision is TriggerStay and one time it's TriggerExit
     
    Last edited: Nov 5, 2023