How do I use "applyImpulse"?
by Jason Doiron · in Torque Game Engine · 09/09/2005 (1:59 pm) · 19 replies
I'm trying to use the applyImpulse function for the player object (in the FPS example). I tried this: player.applyImpulse(0, 0, 100);
to make the player "Jump" super high. that's not the right way, so what is the right way? Its hard to know, for any functions, because I can't see where they're defined, so I can know what arguments they take.
to make the player "Jump" super high. that's not the right way, so what is the right way? Its hard to know, for any functions, because I can't see where they're defined, so I can know what arguments they take.
#2
Your best bet is to use TorqueDev, my free Torque IDE. It has exactly the feature you request, plus a lot more. Check the website for more info.
TD dumps this when I autocomplete on player:

The function accepts 2 parameters, a Point3F and a VectorF.
If I understand this correctly, you'd format that to something like:
%player.applyImpulse("0 0 0", "0 0");
It asks for position (3F) and velocity (vector). What you put in there is, of course, entirely up to you.
09/09/2005 (2:15 pm)
Quote:
Its hard to know, for any functions, because I can't see where they're defined, so I can know what arguments they take.
Your best bet is to use TorqueDev, my free Torque IDE. It has exactly the feature you request, plus a lot more. Check the website for more info.
TD dumps this when I autocomplete on player:

The function accepts 2 parameters, a Point3F and a VectorF.
If I understand this correctly, you'd format that to something like:
%player.applyImpulse("0 0 0", "0 0");
It asks for position (3F) and velocity (vector). What you put in there is, of course, entirely up to you.
#3
09/09/2005 (2:25 pm)
Wow. Nice tool.
#4
09/09/2005 (3:19 pm)
VectorF is a PointF, therefore, it would be in the format applyImpulse("x y z", "x y z");
#5
09/09/2005 (3:21 pm)
Yup, I phrased my earlier post after reading the source code :)
#6
09/09/2005 (3:58 pm)
The velocity makes sense, but what is the position of the impulse used for?
#8
09/09/2005 (4:03 pm)
So what does? Vehicles?
#9
09/09/2005 (4:06 pm)
Yes :)
#10
09/09/2005 (4:07 pm)
In the case of a vehicle or some such, the impulse will cause an angular velocity depending on the position. If you don't want any angular velocity, set the position to (0, 0, 0) - the object's center of mass. Of course, like Matt said, it's irrelevant in your situation. Just thought you might want to know anyway.
#11
09/09/2005 (4:14 pm)
So that's a relative rather than world position to boot. Interesting.
#12
09/09/2005 (4:23 pm)
Good explanation Adam... though if its your player it doesn't even use the position passed... look up in the source to see how all this works :) (would post it if this were private)
#13
I'm used to working with code, not script, and just looking at the function header to know what arguments a function takes (if intellisense isn't available), or even sometimes looking at the function definition to see how it works.
Edit: I just got my jump-pad working :D
09/12/2005 (6:57 am)
That Torquedev program of yours seems good, Sam- but I can't get it working: it always fails to register me for the program, even after I input all my information correctly. I may get it working later, but for now, is there a place where all of these scripts "applyImpulse" and the like are defined? Is it defined in code? I'm used to working with code, not script, and just looking at the function header to know what arguments a function takes (if intellisense isn't available), or even sometimes looking at the function definition to see how it works.
Edit: I just got my jump-pad working :D
#14
09/14/2005 (12:35 am)
Sorry for getting back to you so late. I just updated the verification script for TSE to the latest CVS. You can try again and if you run into any snags, email me.
#15
awesome. I'll post in there from now on.
09/14/2005 (7:28 am)
if you post in the private forums (since you've purchased the engine) I could post the source code functions this callsawesome. I'll post in there from now on.
#16
03/15/2006 (8:11 am)
Can anybody explain the significance of both parameters in applyImpulse(const Point3F&,const VectorF& vec) function.
#17
03/15/2006 (8:14 am)
Hey, is there anybody who can help me with calculating force. I am applying impulse to an item class object, I want that object to reach my desired destination when i say applyImpulse( pos, vel); I am doing this in a *.cc file.
#18
the second is the vector applied, so "0 0 1" would apply a speed of 1 world units / second in vertical direction i believe.
im not sure how to pinpoint how to get an object to be moved (so not translated) to a point object (in script NOR c++) if you by now have figured it out, please post something here. it would be very helpfull for me and others.
@ jason, wouldnt it be wiser to make a superjump function to your player through c++. if ur not wise a programmer (like me) you could still do this pretty easily just copying all fields and pasting, renaming. in that way you might be able to link, say $mvTriggerCount3 to the new superjump, and then just add those fields to your player datablock; for example after existing fields:
jumpForce = 8.3 * 90;
jumpEnergyDrain = 0;
minJumpEnergy = 0;
jumpDelay = 15;
add this:
superJumpForce = 8.3 * 90;
superJumpEnergyDrain = 0;
minSuperJumpEnergy = 0;
superJumpDelay = 15;
also if you redefine any of these for your superjump be sure to add some new too:
runSurfaceAngle = 70;
jumpSurfaceAngle = 80;
minJumpSpeed = 20;
maxJumpSpeed = 30;
anyhow, you will have to add those fields through the engine and recompile.
07/23/2007 (8:28 am)
The Point3F is the position the force is applied FROM i believe, this causes some objects, like vehicles to start spinning if its not from their own centre of mass.the second is the vector applied, so "0 0 1" would apply a speed of 1 world units / second in vertical direction i believe.
im not sure how to pinpoint how to get an object to be moved (so not translated) to a point object (in script NOR c++) if you by now have figured it out, please post something here. it would be very helpfull for me and others.
@ jason, wouldnt it be wiser to make a superjump function to your player through c++. if ur not wise a programmer (like me) you could still do this pretty easily just copying all fields and pasting, renaming. in that way you might be able to link, say $mvTriggerCount3 to the new superjump, and then just add those fields to your player datablock; for example after existing fields:
jumpForce = 8.3 * 90;
jumpEnergyDrain = 0;
minJumpEnergy = 0;
jumpDelay = 15;
add this:
superJumpForce = 8.3 * 90;
superJumpEnergyDrain = 0;
minSuperJumpEnergy = 0;
superJumpDelay = 15;
also if you redefine any of these for your superjump be sure to add some new too:
runSurfaceAngle = 70;
jumpSurfaceAngle = 80;
minJumpSpeed = 20;
maxJumpSpeed = 30;
anyhow, you will have to add those fields through the engine and recompile.
#19
02/26/2009 (12:52 pm)
Wait so where do you add the apply.impulse() function in player.cs? If so how can you make like a double jump
Torque 3D Owner Matthew Langley
Torque
player.applyImpulse("posX posY posZ", "velX velY velZ");
if you post in the private forums (since you've purchased the engine) I could post the source code functions this calls