Unofficial LSL Reference

[[functions:llapplyimpulse]]


Unofficial LSL reference

User Tools

Login

You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.

Login

Forgotten your password? Get a new one: Set new password

Function: llApplyImpulse

llApplyImpulse(vector impulse, integer local)

Apply an instant impulse (a change in the linear momentum, like a "kick") to a physical object (or the avatar if it's in an attachment). It has no effect on non-physical objects.

Parameters

impulse

A vector specifying the impulse to apply. Impulse is expressed in units of lindograms·m/s. For example, in absence of other effects such as gravity or friction, applying an impulse vector of <1, 0, 0> to an object with a mass of 1.25 lindograms will add a velocity of 0.8 m/s in the given direction (applied according to the local parameter).

local

Boolean value indicating whether the impulse vector applies its effect in coordinates local to the root prim or avatar (if TRUE) or in sim coordinates (if FALSE).

When TRUE, the impulse vector specifies coordinates local to the root prim. For example, if impulse is <1, 0, 0> and the X axis of the root prim is looking northwest, then the impulse will be applied in the northwest direction, aligned with the root prim's X axis. If it's an attachment, the vector is relative to the avatar's orientation.

When FALSE, the vector specifies sim coordinates, where positive X is east, positive Y is north, positive Z is up, and vice versa for negative; for example, if impulse is <-1, 0, 0>, the impulse will be applied in the westward direction, no matter how the root prim or the avatar is oriented.

Notes

  • To change the velocity of the object by a given amount, multiply the desired velocity difference by its mass in Lindograms (see example below).
  • The maximum speed (magnitude of the velocity vector) of an object seems to be limited to 202.8125 m/s, although the value measured by llGetVel can be greater for an instant before it is actually applied. The value returned by llGetVel seems to be limited to a magnitude of 250 m/s.
  • FIXME: official wiki says total momentum has a cap too. Test.

Short examples

llApplyImpulse(<0, 0, 5>, FALSE); // Applies an impulse to a physical object, making it "jump".
llApplyImpulse(<3, 4, 0>*llGetMass(), TRUE); // Adds <3,4,0> m/s to a prim.
                                             // If it wasn't moving, its final speed will be 5 m/s
                                             // (the length of that vector).

See also