ApplyImpulse on flyingVehicle...help?
by Chad Kilgore · in Torque Game Engine · 08/02/2007 (10:44 am) · 1 replies
I am trying to create a "current" system in an underwater game. Its implementation thus far uses a trigger that applies an impulse (applyImpulse) when a player enters it. I would like to extend this so that the impulse is applied until the player leaves the trigger.
However, my problem is that the applyImpulse function causes the player (a flyingVehicle) to spin randomly as opposed to being pushed out of the trigger space.
My current script reads:
Can anybody help me out? Thanks.
However, my problem is that the applyImpulse function causes the player (a flyingVehicle) to spin randomly as opposed to being pushed out of the trigger space.
My current script reads:
datablock TriggerData( CurrentTrigger ) {
tickPeriodMS = 100;
isIn = false;
};
//-----------------------------------------------------------------------------
function CurrentTrigger::onEnterTrigger(%this, %trigger, %obj)
{
%this.isIn = true;
%obj.setVelocity("0 0 0");
%this.whileInTrigger(%obj);
}
function CurrentTrigger::onLeaveTrigger(%this, %trigger, %obj)
{
%this.isIn = false;
}
function CurrentTrigger::whileInTrigger(%this, %obj)
{
%pos = getBoxCenter(%obj.getWorldBox());
%obj.applyImpulse(%pos, "0 0 -20000");
}Can anybody help me out? Thanks.
Torque Owner Brian Hill