applyImpulse on surface vs in air.
by Dustin Mellen · in Torque 3D Professional · 09/20/2010 (4:34 am) · 7 replies
Can anyone explain to me why applyImpulse affects the player differently when they are on a surface as opposed to in mid air? I've been wanting to apply a "knock back" effect to the player when colliding with enemy objects but, when applyImpulse is called while the player is in mid air it is thrown much farther than when standing on a surface. Is there any way to make the two effects equal?
About the author
Just a guy trying to live his childhood dream.
#2
09/21/2010 (1:54 pm)
Well, there seems to be a vast difference between the distance you are pushed when on a surface compared to when you are in the air. I set my impulse value on the x-axis to 5000 and that throws the player the distance I was looking for (a couple meters), but when applied in mid air it throws the player ten times as much (I'm not sure how far because the player hits a wall first).
#3
09/21/2010 (2:02 pm)
Is there another way to apply a "knock back" effect? Should I just use the eye vector and multiply that by the distance I want to move the player back and apply it to .setTransform()?
#4
09/21/2010 (4:20 pm)
Have you tried adding a small vertical component to the knockback impulse so that it lifts the player off the ground slightly?
#5
09/21/2010 (7:50 pm)
I tried that, but as soon as the player makes contact with the floor, the brakes come on and he stops. If he's in the air to start, it still goes too far.
#6
09/21/2010 (7:57 pm)
If you look in the Movement fields in the PlayerData datablock there are a number of different settings that kick in based on whether or not the Player is in contact with the surface (particularly look at the various max speeds and the resist speeds). If there are different values for these, then it would make sense that you would get different results from an impulse.
#7
09/21/2010 (9:52 pm)
Regardless of how I set the horizMaxSpeed, horizResistSpeed, or the horizResistFactor, I get the same result. When the player is in the air, applyImpulse throws him like a bullet. As soon as he touches a horizontal surface, he stops on a dime. It's like he as 100% friction on his feet.
Torque Owner deepscratch
DeepScratchStudios