Search Unity

OnTriggerEnter2D triggering again when moving around inside the trigger.

Discussion in 'Physics' started by renderling, Jan 7, 2016.

  1. renderling

    renderling

    Joined:
    Jan 6, 2016
    Posts:
    3
    I've got a player GameObject with a kinematic RigidBody2D and a BoxCollider2D on it, along with a water area that has a trigger BoxCollider2D. For some reason, OnTriggerEnter2D() is called on the player even when the player is already inside the water area's collider. If the player doesn't move, then OnTriggerEnter2D() isn't called, but as soon as the player starts moving again OnTriggerEnter2D() is called again. Also, It appears to only be called on the first frame of movement. I'm currently moving the player object via RigidBody2D.MovePosition(). The same also happens if I just set the player GameObject transform position directly.

    I'd appreciate any help anyone can provide. I've been looking through the documentation, but haven't found anything that would explain this behavior.

    Thanks!
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,455
    That is very strange indeed. I would ask that you create a bug report (with a super simple reproduction project) and post the case number here so I can take a look at it for you.
     
    Last edited: Jan 9, 2016
  3. renderling

    renderling

    Joined:
    Jan 6, 2016
    Posts:
    3
    Thanks! I'll strip things down to a simple repro and send it your way.
     
  4. renderling

    renderling

    Joined:
    Jan 6, 2016
    Posts:
    3