Author Topic: Alternative to trigger colliders while dragging.  (Read 2932 times)

Neverdyne

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Alternative to trigger colliders while dragging.
« on: January 16, 2014, 05:23:27 PM »
Hello there, I'm making a scene where the player can drag a few sprites around, however I need to know if the sprites hit a trigger collider while being dragged. This only works when the player releases the dragged item and the item returns to it's original parent, passing through the collider on its way back, but it doesn't work when the player is dragging the item. I believe this is because when you drag an item the box collider in it is disabled, so the trigger collider can't detect a collision. Does anyone know a good and efficient way to detect collisions between static triggers and the dragged item, or at least provide the same functionality in a different way?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Alternative to trigger colliders while dragging.
« Reply #1 on: January 16, 2014, 10:26:33 PM »
Easiest and fastest way is to do your own math. Simple 2D rectangle intersection test would do it.

Neverdyne

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Alternative to trigger colliders while dragging.
« Reply #2 on: January 16, 2014, 10:46:34 PM »
Thanks for the reply! What I ended up doing was making my draggable item have a child transform with a collider of its own, seems to work so far.