Game Development Community

Has anyone got Impulse to work?

by Matt W · in Torque Game Engine · 03/01/2002 (2:47 pm) · 4 replies

Impulse is a script function which can be found in radiusDamage.cs and supposedly alters the movement vector of the player to reflect an outside force (explosion, punch, etc)

I've worked with it, and I get no errors... but no force change.

The main reason I'd like this is for a "knockback" effect of explosives (you can rocketjump... of course, you die from it hehe)

When I get home from work I plan on looking into the C++ code of the impuse function to see what's going on inside of it.

Thanks for any info that can be provided!

#1
03/01/2002 (3:10 pm)
Try,

obj.applyImpulse(pos,vector);
#2
03/01/2002 (4:47 pm)
I use impulse to let the player push things around, I haven't used it on the player itself yet, so I'm not sure about that. But it does work.
#3
03/02/2002 (12:03 am)
I worked with the code a bit and yes. That function is what is used, but it took me a while before I realized why it wasn't working.

The weapon projectiles didn't have an impulse variable, so the default impulse was 0. Since the if statement wouldn't run if the impulse was false (<=0) I created a field for the impulse of the weapon, and then made sure the damageRadius function was called with it.

Well... it didn't seem to be working.

Why? Because the vector created was too small to be noticable. I integrated a small "physics" fix which accellerates the object based on it's mass. So a fat player might only get knocked back a tiny bit, but the tiny player or object would get launched across the room.

I'll write up a tutorial for this over the weekend, since it's pretty fun to play around with. We'll be using it for explosions knocking players around (no rocket jumping though hehe)
#4
04/10/2003 (4:15 pm)
Did this tutorial ever get posted? I am working on the same thing.

edit:
My bad for not looking first. Here it is if anyone finds this thread and needs it.

www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2302