Don't click here unless you want to be banned.

LSL Wiki : llApplyImpulse

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl801.us.archive.org
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.

Because there is no air friction, any impulse off the vertical (gravity) axis will cause the object to keep moving forever. Hence, this can be used to set a velocity.

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

Q:Is it possible to apply Impulses to other peoples objects that havn't been scripted to do so?

Limitations

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


This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Dynamics | Force | Impulse
Comments [Hide comments/form]
A good hack I found to 'set' the velocity of an object is the following: llApplyImpulse( ((llGetVel() * -1) + (desiredvel)) * llGetMass, FALSE), with desiredvel being the velocity you'd like. In this way, then, you can make an object move at a constant velocity when this is called in a loop (don't forget to llSleep!), which is useful for things such as elevators.
-- CharlesFauna (2004-10-13 06:12:25)
That's not a hack, it's math that works :)
The function posted above basically does that, but accounts for the rotation of the object as well. (I think)
Its a bit bloated though, I should beautify it a bit.
-- ChristopherOmega (2004-10-13 13:28:02)
I'm simplifying the code a bit :p
-- BlindWanderer (2004-10-15 04:20:32)
This function (along with llPushObject) seems to be capped to a maximum force proportional to the size of the scripted object, including for attachments. This means that small attachments will not be able to propel users to great speeds.
-- ElteeStatosky (2005-03-16 22:24:21)
I think in the formula "I=M*V," the I should be replaced with "p," the abbreviation for momentum.
-- DolusNaumova (2005-08-18 07:47:05)
Right, I is the standard abbreviation for current and V is the standard for voltage.
I changed it to read "p = m*v"
-- ChristopherOmega (2005-08-18 11:14:19)
After one applies an impulse(and you llSetPos() it), it seems to annoyingly bounce whoever gets on it. Why does it do this, and is there any way to solve it?
-- VirusCollector (2006-11-14 19:35:08)
Is it possible to combine llApplyImpulse with a sensor or collision to push people?
-- cpe-66-108-79-161.nyc.res.rr.com (2007-09-23 06:08:09)