Rigid Shape rest event
by Frank Korf · in Technical Issues · 03/21/2007 (7:48 am) · 2 replies
Hey- I'm still learning the TGE
Let's say I have a rigid shape, such as a boulder, and it is rolling down a hill. I want to call a function when the boulder comes to a stop. Is there any event function like this currently in the TGE, like an OnRest function?
If not, can anybody give me some pointers on how to start implementing it?
Thanks in advance.
Let's say I have a rigid shape, such as a boulder, and it is rolling down a hill. I want to call a function when the boulder comes to a stop. Is there any event function like this currently in the TGE, like an OnRest function?
If not, can anybody give me some pointers on how to start implementing it?
Thanks in advance.
#2
I already have the rigid body in the game. My question is specifically about the "onRest" event
I have made progress by changing this code in rigidShape.cc (line 930)
from
The only problem is that it calls the "onRest" function every frame that the boulder is at rest, not just once when it begins to rest. Make sense? Any advice/direction would be greatly appreciated.
Side note: This is the first time I've used the executef function, so feel free to let me know if I have misused it.
03/21/2007 (10:00 am)
Thanks for the response. I should have been more clear:I already have the rigid body in the game. My question is specifically about the "onRest" event
I have made progress by changing this code in rigidShape.cc (line 930)
from
if (mCollisionList.count)
{
F32 k = mRigid.getKineticEnergy();
F32 G = sRigidShapeGravity * dt;
F32 Kg = 0.5 * mRigid.mass * G * G;
if (k < sRestTol * Kg && ++restCount > sRestCount)
mRigid.setAtRest();
}toif (mCollisionList.count)
{
F32 k = mRigid.getKineticEnergy();
F32 G = sRigidShapeGravity * dt;
F32 Kg = 0.5 * mRigid.mass * G * G;
if (k < sRestTol * Kg && ++restCount > sRestCount)
{
Con::executef(mDataBlock, 1, "onRest", scriptThis());
mRigid.setAtRest();
}
}The only problem is that it calls the "onRest" function every frame that the boulder is at rest, not just once when it begins to rest. Make sense? Any advice/direction would be greatly appreciated.
Side note: This is the first time I've used the executef function, so feel free to let me know if I have misused it.
Associate David Montgomery-Blake
David MontgomeryBlake