Game Development Community

Object status

by George Balla · in Torque Game Builder · 08/21/2006 (2:41 pm) · 1 replies

I have a ball that has physics attributes added to it. The ball bounces around the screen until it stops.
How do I know when there is no more movement on that ball?

Is there an event that triggers when it stops?

#1
08/21/2006 (6:07 pm)
George, I've not yet run into any callbacks that can be assigned to physics ... what I've been doing is setting timers on the objects and testing there linear and angular velocities and if below a certain threshold (at a certain point, they just slow down to a point where they appear as though no longer moving) I simply stop the timer and setAtRest() the object and then call my own callback ...

$MIN_MOVE = 1.0;
$MIN_ROTE = 1.0;
$obj.setLinearVelocityPolar(45, 45);
$obj.setTimerOn(100);

function obj::onTimer(%this)
{
  %angspd = $obj.getLinearVelocityPolar();
  if(getWord(%angspd, 0) < $MIN_ROTE && getWord(%angspd,1) < $MIN_MOVE)
  {
    $obj.setAtRest();
    $obj.isAtRest(); // my 'callback'
  }
}

for example