Alternative Air Control
by Jeremy Alessi · in Torque Game Engine · 02/13/2005 (1:33 pm) · 2 replies
Now I've seen the resource Air Control but it seems to be somewhat unstable judging by the comments.
It seems to me that horizontal velocity could be applied inside the player::updateMove function.
This bit of code is where the player is falling if not on a runSurface. Is it possible to add horizontal velocity here due to input? Any recommendations from some advanced Torque C++ users?
It seems to me that horizontal velocity could be applied inside the player::updateMove function.
This bit of code is where the player is falling if not on a runSurface. Is it possible to add horizontal velocity here due to input? Any recommendations from some advanced Torque C++ users?
// If we are not touching anything and have sufficient -z vel,
// we are falling.
if (runSurface)
mFalling = false;
else {
VectorF vel;
mWorldToObj.mulV(mVelocity,&vel);
mFalling = vel.z < sFallingThreshold;
}About the author
#2
I have another question. The air control is a pretty important aspect and it seems like it was implemented fairly well ... is that something that should be added to the engine permanantly? Seems to me that it should but I guess it's tricky with such a large codebase.
This brings me to another topic ... I want to add a double jump function to the game. I was able to hack something really quick by toying with the mContactTimer (letting you jump so long as the timer was above a certain numer). That of course just let you jump in mid air as much as you want.
Now I could probably rig something by letting you jump and using the jump energy drain capability of the player datablock but that might not work exactly right.
Adding something to the engine requires quite a bit of design insight because you want to be able to tweak in in the script (as the air control lets you do). Now with a double jump function you could have just an action flag (doubleJump) that says:
if (canJump)
{
doubleJump = false;
}
if (move->trigger[2] && doubleJump = false && mContactTimer > 5)
{
doubleJump = true;
//do jump stuff;
}
that seems like the best bet but of course you'd probably want to add a flag to the datablock also that either allows for double jumping or not.
Anyway, from the air control example I know how to add a field to the data block but I'm not sure how to implement an action flag best. Something that just says hey we double jumped ... we can't do it again until we touch the ground. What's the best way to implement that into the engine? I guess I'll look for the player struct and add a bool variable to that. What would be best considering the overall design of the engine?
02/13/2005 (8:32 pm)
Thanks ... I implemented the other air control example and it seems to work decent for what I need.I have another question. The air control is a pretty important aspect and it seems like it was implemented fairly well ... is that something that should be added to the engine permanantly? Seems to me that it should but I guess it's tricky with such a large codebase.
This brings me to another topic ... I want to add a double jump function to the game. I was able to hack something really quick by toying with the mContactTimer (letting you jump so long as the timer was above a certain numer). That of course just let you jump in mid air as much as you want.
Now I could probably rig something by letting you jump and using the jump energy drain capability of the player datablock but that might not work exactly right.
Adding something to the engine requires quite a bit of design insight because you want to be able to tweak in in the script (as the air control lets you do). Now with a double jump function you could have just an action flag (doubleJump) that says:
if (canJump)
{
doubleJump = false;
}
if (move->trigger[2] && doubleJump = false && mContactTimer > 5)
{
doubleJump = true;
//do jump stuff;
}
that seems like the best bet but of course you'd probably want to add a flag to the datablock also that either allows for double jumping or not.
Anyway, from the air control example I know how to add a field to the data block but I'm not sure how to implement an action flag best. Something that just says hey we double jumped ... we can't do it again until we touch the ground. What's the best way to implement that into the engine? I guess I'll look for the player struct and add a bool variable to that. What would be best considering the overall design of the engine?
Associate Kyle Carter