Jumping carrying velocity issue
by Matt James · in Torque Game Builder · 11/21/2012 (11:34 am) · 1 replies
GAME:
Think castle crashers / streets of rage.
AKA - You can move in both the X/Y direction as well as jump.
NOTE:
I'm a complete n00b, so forgive my n00bness and embrace my willingness to learn =O)
I'm aware of how I can use various "Gets" to get my players X/Y velocity as well as Polar angle/speed.
What i'm not sure is what exactly to do with this information to write a function that does a "jump" (set amount in -Y) but still CARRIES whatever velocity/angle your player is already moving at with them.
For instance, if are moving up & right in at a 45 degree angle, do I need to use a tangent (or some other trig function) to find out what the opposite angle is, and set it to "descend" the jump based on that angle ?
Most importantly, i'm not sure what the most efficient way to do this is ... Here's some thoughts I had:
1) disable movemap, carry angle/velocity through and use a trig function to find the inverse angle? Use a timer or schedule to start the movement descend after 500ms or so ?
2) use the MoveTo function ?
3) manually set a LinearVelocityY, add gravity with a timer, then shut off gravity on timer reached?
Any other suggestions are welcome, if I can get a suggestion on the best/most efficient way of going about this and I can write up some code and post it for further suggestions.
Thanks !
Think castle crashers / streets of rage.
AKA - You can move in both the X/Y direction as well as jump.
NOTE:
I'm a complete n00b, so forgive my n00bness and embrace my willingness to learn =O)
I'm aware of how I can use various "Gets" to get my players X/Y velocity as well as Polar angle/speed.
What i'm not sure is what exactly to do with this information to write a function that does a "jump" (set amount in -Y) but still CARRIES whatever velocity/angle your player is already moving at with them.
For instance, if are moving up & right in at a 45 degree angle, do I need to use a tangent (or some other trig function) to find out what the opposite angle is, and set it to "descend" the jump based on that angle ?
Most importantly, i'm not sure what the most efficient way to do this is ... Here's some thoughts I had:
1) disable movemap, carry angle/velocity through and use a trig function to find the inverse angle? Use a timer or schedule to start the movement descend after 500ms or so ?
2) use the MoveTo function ?
3) manually set a LinearVelocityY, add gravity with a timer, then shut off gravity on timer reached?
Any other suggestions are welcome, if I can get a suggestion on the best/most efficient way of going about this and I can write up some code and post it for further suggestions.
Thanks !
Torque Owner Kevin James
I'm writing a platformer; for me, setting a constant, gravitic force on the player and then using setImpulseForceY for jump works beautifully. It's probably just about as elegant as possible.
Since in your game the player can move in both x and y direction, the setting a constant, gravitic force on the player is a no go. But I think that you can still use setImpulseForce to win. You'll probably have to keep track of some "Z" dimension on your player sprite in order to know how long he has to fall. You can take current X/Y velocity into account in your setImpulseForceX/Y by adding more force for more velocity or something like that.