LSL Wiki Mirror : llApplyImpulse

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings ::
llApplyImpulse(vector force, integer local)

If an object is physical, this call applies a single push in a specific direction to the object defined by the argument force. If local is true, force is applied along the object's local axis, otherwise it is applied along the global axis.

Note: unlike llApplyRotationalImpulse, llApplyImpulse does work on attachments.

To set the object's velocity using llApplyImpulse():
setVel(vector newVel, integer localAxis)
{
     vector curVel = llGetVel();
     
     if(localAxis)
     {
          rotation rot = llGetRot();
          curVel /= rot; // Un-rotate curVel.
     }

     newVel -= curVel;
     newVel *= llGetMass();

     llApplyImpulse(newVel,localAxis);
}

Compare with llApplyRotationalImpulse.


llApplyImpulse(llGetMass()*<0,0,10>,FALSE);
//10 meters per second upwards
//Gravity will slow the object down immediately and make it fall back

To overcome gravity effects, use a force which, unlike an impulse, is constant over time:

llSetForce(<0,0,9.8>*llGetMass(),FALSE);
// will cancel the effects of gravity

To stop a moving object dead in its tracks, apply an impulse to counter its current impulse:

llApplyImpulse(-llGetMass()*llGetVel(),FALSE);
//This will cancel the speed of an object that has no other forces set on it
//and will cause it to stop in place relative to the ground

Limitations

The actual impulse may be less than requested for two reasons.


Functions | Dynamics | Force | Impulse
There are 7 comments on this page. [Display comments/form]