Game Development Community

Great difficulty with applyImpulse()

by Mr Meikel · in Torque Game Engine · 02/25/2006 (3:45 pm) · 2 replies

Hi,

I'm have a lot of problems with applyImpulse(), I can't make it do anything at all to anyone!

Can someone give me an example of how to use this function? I've never really gotten my head around how torque script "does" vectors :s

Eg. I have a Player/AIPlayer standing stationary at position %pos, i want them to get thrown into the air - what would the correct command be?

Thanks, and sorry for the newbie question!

#1
02/25/2006 (3:56 pm)
To get applyImpulse to work I use something like this:
%vec = "0 0 1000";
%obj.applyImpulse(%obj.getPosition(), %vec);


Where %obj is a reference to the object I want to launch, %obj.getPosition is the location it applies the impulse(pretty sure) and %vec is an xyz vector that indicates the direction and force of the launch (in this case straight up in the air).

Torque script's vector format is actually a string which took me a little while to get used to as well. Be sure to check out the vector functions if you want to manipulate them.
#2
02/25/2006 (5:20 pm)
Ok, turns out I just wasn't using high enough values for the actual impulse, I though 100 etc should get me pretty far off the ground :x

Stupid mistake #3599 - noted

Thanks for your help anyway, I heard from somewhere that the first parameter should be "0 0 0" as it's not in worldco-ords but the %obj's co-ords - I was on the wrong track :)