Game Development Community

Collision only in one direction (UP to down)

by Adam Johnston · in Torque Game Builder · 10/17/2005 (10:42 am) · 3 replies

Hello
Is possible to implement a collision system only in one direction?
(when the player is falling he can stop on a tile)
but when the player is flying upwards he can surpass the tile)
Regards

#1
10/17/2005 (10:58 am)
You could probably just set a flag on the player. If he's falling then your tile collisions work as expected and if he's flying you just bail out of the onCollision callback without doing anything.
#2
10/17/2005 (12:27 pm)
Just noticed you had also posted this another thread. I'll copy my answer here in case that one does get deleted...
--------------------------------------------------------------------------------------------------------------------------------------------------

I have it working in script only. It makes some assumptions and there are better ways to do it in code, but from a players point of view it works. Which in the end is all that matters, right. :)

Basically you just need to add your one way platforms in a different layer or add custom data tags or some way to tell them apart from solid objects.
Then in the onCollision, if the y value of the collision normal is >1 and it's one of the one-way platforms
I'm suppressing collision and scheduling it to be re-enabled after 250 ms
Next it's giving a boost to the player to send them back in the up direction.

I can post the code I'm using when I get home if you want it.

--Tom
#3
10/17/2005 (3:06 pm)
@Tom: thank you, It would be nice to see your code, modifying
the physics engine that melv suggest is not an option
right now for me. Sorry for the doble post, my finger just slipped out...