Search Unity

Rotating Triggers

Discussion in '2D' started by DigiScot, Dec 11, 2013.

  1. DigiScot

    DigiScot

    Joined:
    Aug 23, 2013
    Posts:
    27
    Hi all,

    If you have a simple sprite that has a Box2D collider set as a trigger, and rotate it, either using the animator, or via a script like:

    transform.Rotate (new Vector3(0,0,Time.deltaTime * speed));

    the trigger doesn't fire:

    void OnTriggerStay2D (Collider2D col) {
    Debug.Log ("touching the rotating wall :p");
    }

    if you stop the rotating, or animator, or even if you have a brief moment of it being in the same rotation... it works!!

    Am I doing something wrong, or unusual?

    Thanks
    DigiScot
     
  2. softwizz

    softwizz

    Joined:
    Mar 12, 2011
    Posts:
    793
    maybe the collider isnt being collided with at certain parts of its rotation.

    Does using:

    void OnTriggerEnter2D(Collider2D col)

    instead have the same effect.
     
  3. DigiScot

    DigiScot

    Joined:
    Aug 23, 2013
    Posts:
    27
    Thanks softwizz, this works, and will get me by for now, but doesn't feel like it should, something definitely up with these colliders.