Bouncing items
by Radoslaw Marcin Kurczewski · in Torque Game Engine · 09/15/2003 (3:22 am) · 2 replies
Hi,
I would like to get barrel that can be hit and bounced by car.
Here is datablock used by my dynamic barrels:
And this is 'onCollision' handler:
All above works fine except that there is some gap between message 'DynBarrel is colliding...' and actual action. I manage to pass the barrel and it takes about 1 sec. to apply impulse to it, which looks really weird.
Another problem: when barrel lands on slope of the hill (name it 'landPos') it starts sliding down, then instantly move back to the 'landPos' and repeats that constantly. I tried to set sticky to 1, but now it is much harder to move barrel at all...
I would be very grateful for any help...
I would like to get barrel that can be hit and bounced by car.
Here is datablock used by my dynamic barrels:
datablock ItemData( DynBarrel )
{
mass = 1;
sticky = true; // See further...
category = "Addons";
className = "DynBarrel";
shapeFile = "~/data/shapes/misc/barrel1.dts";
static = false;
rotate = false;
};And this is 'onCollision' handler:
function DynBarrel::onCollision( %this, %obj, %col, %vec, %speed )
{
error( "DynBarrel is colliding with" SPC %col.getClassName() );
%objPos = %obj.getPosition();
%colPos = %col.getPosition();
%impulseVec = VectorSub( %objPos, %colPos );
%vX = getWord( %impulseVec, 0 );
%vY = getWord( %impulseVec, 1 );
// Limit movement to horizontal plane...
%impulseVec = %vX SPC %vY SPC "0";
%impulseVec = VectorNormalize( %impulseVec );
%impulseVec = VectorScale( %impulseVec, 50 );
%obj.applyImpulse( %objPos, %impulseVec );
}All above works fine except that there is some gap between message 'DynBarrel is colliding...' and actual action. I manage to pass the barrel and it takes about 1 sec. to apply impulse to it, which looks really weird.
Another problem: when barrel lands on slope of the hill (name it 'landPos') it starts sliding down, then instantly move back to the 'landPos' and repeats that constantly. I tried to set sticky to 1, but now it is much harder to move barrel at all...
I would be very grateful for any help...
#2
09/15/2003 (4:31 am)
I run the game on single machine, so I would rather not expect client-server miscommunication... (but maybe I'm wrong)
Associate Kyle Carter