Jump through platforms?
by dan hussey · in Torque Game Builder · 01/11/2010 (10:09 am) · 5 replies
I was just wondering if anyone could help me.
I am trying to write some code to make the player character jump through platforms (and then land on top of them), instead of hitting his head on them. I have tried for hours and can only get the guy to jump through them but he doesn't land on them. I am a newbie when it comes to torque script; even just a pointer or two in ways to tackle the code would be great.
I am trying to write some code to make the player character jump through platforms (and then land on top of them), instead of hitting his head on them. I have tried for hours and can only get the guy to jump through them but he doesn't land on them. I am a newbie when it comes to torque script; even just a pointer or two in ways to tackle the code would be great.
#2
(Edit) It works!, thanks for the help.
01/13/2010 (10:09 am)
@Steven. Thank you for your input, I'll give it a go.(Edit) It works!, thanks for the help.
#3
01/16/2010 (10:25 am)
Glad I could help!
#4
I've managed to set up one way platforms on my prototype using triggers, but I'm getting some odd jumping glitches and I think the above solution would work a million times better for what I'm trying to do.
Thanks in advance!
08/23/2010 (11:34 pm)
Would either of you fine gentlemen mind showing us "mentally challenged coders" the actual code you used to do this? This is exactly what I'm looking for.I've managed to set up one way platforms on my prototype using triggers, but I'm getting some odd jumping glitches and I think the above solution would work a million times better for what I'm trying to do.
Thanks in advance!
#5
if(player moving up)
turn off collisions
else
turn on collisions
You would want to put more logic in here so that collisions are not being turned on or off every update, but this is the general idea. Also there would be a problem of having other objects miss the player when jumping. This is something you would need to figure out. Of course if it's not relevant to your game then this will work.
I'll keep working to see what I can come up with...
08/24/2010 (12:26 pm)
The basic logic is:if(player moving up)
turn off collisions
else
turn on collisions
function Player::onLevelLoaded(%this, %scene)
{
%this.enableUpdateCallback();
}
function Player::onUpdate(%this)
{
if(%this.getLinearVelocityY() < 0)
{
%this.setCollisionActiveReceive(false);
} else if(!%this.getCollisionActiveReceive())
{
%this.setCollisionActiveReceive(true);
}
}You would want to put more logic in here so that collisions are not being turned on or off every update, but this is the general idea. Also there would be a problem of having other objects miss the player when jumping. This is something you would need to figure out. Of course if it's not relevant to your game then this will work.
I'll keep working to see what I can come up with...
Torque Owner Steven Hine
or, a better way might be to put all platforms on a different collision layer, and disable that layer when a player is moving up and enable it when they are moving down. This would not effect the rest of the NPC's in the game. this is probably the easiest way.
Steve