Game Development Community

Contorlling collision??

by Firas · in Torque Game Builder · 10/05/2006 (10:51 pm) · 2 replies

Hi guys

I have some problem about collision, and my problem is I wont to specify with which side I have collision, so if the collision happen from the fromt of the player there will be a specific action, if it's hapen from the back there will be another action and if it's happen from left or right there will be 3rd action.

now the problem is castCollision(0.005) will check collision from all direcion, so how can I customize it to specify with side i'm colliding with??

#1
10/06/2006 (10:37 am)
I'd just do something like (this is pseudocode, mind you):

player::onCollision(%srcObj, %dstObj, etc...)
{
     if(%srcOb.getPositionX() < %dstObj.getPositionX())
     {
          if(%srcOb.getPositionY() < %dstObj.getPositionY())
          {
               //do some action A
          }
          else
          {
               // so some action B
          }
     }
     else
     {
          if(%srcOb.getPositionY() < %dstObj.getPositionY())
          {
               //do some action C
          }
          else
          {
               // so some action D
          }
     }
}

That make sense?
#2
10/07/2006 (2:58 am)
You could also just check the collision normal that's passed to the onCollision callback.