Game Development Community

Rigid Shape Collision Detction on Terrain

by Dark Martyr · in Torque Game Engine · 08/11/2008 (8:34 am) · 0 replies

My scenario is this.

I want to throw an object out of the players hand with an impulse attached to it running on a schedule like so.


function throwRock()
{
new RigidShape(rock)
{
dataBlock = blueRock;
position = %initRockPos;
};

rock.applyImpulse(rock.position, %EyeVec);

applyRockSchedule();
}


function applyRockSchedule()
{
rock.applyImpulse(rock.getPosition(), "0 0 10");
$rockSched1 = schedule(300,0, applyLift);
}


function cancelRockSchedule()
{
cancel($rockSched1);
}


My want is that I would like to cancel the schedule once the rock hits the ground.
I figured it would be as ease as this.


function blueRock::onCollision()
{
cancelRockSchedule();
error ("collision");
}


Fortunately once I call the throwRock() function, on a mouse click during runtime, the rock is created, is thrown properly, and has a bounce to it as it flies through the air.

Unfortunately, once it hits the ground and loses momentum it continues to bounce in place.

Any suggestions on why the onCollision isn't being called would be greatly appreciated.

I'm not sure if its due to the fact I'm creating the object during runtime, or the fact that RigidShape objects don't use ground collision. Maybe I'm just overlooking something as usual.