Skip to content
lsl.devlsl.devLSL Dev

Movement

There are three ways to move an object. Non-physical movement sets the position and rotation directly. Keyframed motion plays a smooth path computed by the region. Physical movement applies forces and lets the physics engine move the object.

Non-physical and keyframed movement are predictable and suit doors, platforms and rides. Physical movement suits vehicles, balls and projectiles.

Concepts

Functions and events

voidllSetPos(vector pos)
integerllSetRegionPos(vector position)
voidllSetRot(rotation rot)
voidllSetKeyframedMotion(list keyframes, list options)
voidllMoveToTarget(vector target, float tau)
voidllApplyImpulse(vector momentum, integer is_local)
voidllSetVelocity(vector velocity, integer is_local)
integerllTarget(vector position, float range)
eventat_target(integer tnum, vector targetpos, vector ourpos)
voidllTargetOmega(vector axis, float spinrate, float gain)
voidllSetVehicleType(integer type)

Vehicles

A vehicle type plus float, vector and rotation parameters and flags tune motors, friction and stabilisers.

More on the Second Life Wiki.

Scripting Details

voidllSetPos(vector pos)
Moves the non-physical object or prim toward the vector pos (up to 10m). If called in a child prim, pos is treated as root-relative; if called from the root prim, the entire object is moved.
integerllSetRegionPos(vector position)
Tries to move the entire object so that its root prim is within 0.1m of the vector position (underground positions are set to ground level). Returns TRUE on success or FALSE on failure.
voidllSetRot(rotation rot)
Sets the rotation of the prim to rot. If in a child prim, rot is treated as root-relative; if in the root prim of a non-physical object, rotates the entire object.
voidllSetLocalRot(rotation rot)
Sets the rotation of a child prim relative to its root prim using rot.
vectorllGetPos()
Returns a vector representing the current position of the object in region coordinates.
rotationllGetRot()
Returns a rotation representing the prim's orientation relative to the region's axes.
vectorllGetLocalPos()
Returns a position vector relative to the root prim. If called from the root prim, it returns the global region position (or the position relative to the attachment point if attached).
rotationllGetLocalRot()
Returns a rotation representing the local orientation of a child prim relative to the root prim, or the object's overall rotation if called from the root.
voidllSetScale(vector size)
Sets the physical scale (dimensions) of the prim containing the script to size.
vectorllGetScale()
Returns a vector representing the physical scale (dimensions in meters) of the prim containing the script.
voidllSetKeyframedMotion(list keyframes, list options)
Smoothly moves a non-physical object between the positions, orientations, and times specified in the keyframes list, configured via options. Collisions with keyframed objects are ignored. An empty keyframes list terminates the motion.
voidllMoveToTarget(vector target, float tau)
Critically damps the physical object's motion to position target in tau seconds. Setting tau to 0.0 stops the critical damping; recommended tau values are greater than 0.2.
voidllStopMoveToTarget()
Stops the critically damped movement of the object toward a target (canceling llMoveToTarget). Use llStopLookAt to stop rotational tracking.
voidllLookAt(vector target, float strength, float damping)
Causes the object to orient its positive Z-axis (up axis) toward the target vector, keeping its positive X-axis (forward axis) below the horizon. Tracks target until llStopLookAt is called or strength is set to 0.0.
voidllRotLookAt(rotation target_direction, float strength, float damping)
Causes the object to smoothly rotate to target_direction with a force defined by strength and damping. A strength of 0.0 cancels the rotation target. Rotation is maintained until stopped with llStopLookAt.
voidllStopLookAt()
Stops causing the object to look at or point toward a target (canceling llLookAt or llRotLookAt).
voidllApplyImpulse(vector momentum, integer is_local)
Applies a linear impulse (momentum) to a physical object. If local is TRUE, the impulse is applied in local coordinates; otherwise, it is applied in global region coordinates.
voidllApplyRotationalImpulse(vector force, integer is_local)
Applies a rotational impulse (force) to a physical object. If local is TRUE, the rotational impulse is applied in local coordinates; otherwise, it is applied in global region coordinates.
voidllSetVelocity(vector velocity, integer is_local)
Sets the linear velocity of a physical object to velocity. If local is TRUE, velocity is treated as a local directional vector; if FALSE, as a global region directional vector. Has no effect on non-physical objects.
voidllSetAngularVelocity(vector initial_omega, integer is_local)
Sets the angular velocity of a physical object to initial_omega (mass-independent). If local is TRUE, applied in local coordinates; if FALSE, applied in global coordinates. Has no effect on non-physical objects.
voidllSetForce(vector force, integer is_local)
Applies a constant linear force to a physical object. If local is TRUE, force is applied relative to local coordinates; if FALSE, applied relative to region coordinates.
voidllSetTorque(vector torque, integer is_local)
Applies a constant torque rotational force to a physical object. If local is TRUE, torque is applied in local coordinates; if FALSE, applied in global coordinates.
voidllSetForceAndTorque(vector force, vector torque, integer is_local)
Sets both the constant linear force and constant torque acting on a physical object. If local is TRUE, forces are applied in local coordinates; if FALSE, in global coordinates.
voidllSetHoverHeight(float height, integer water, float tau)
Critically damps the physical object's vertical movement to hover at height (above ground, or above water if water is TRUE) in tau seconds. Do not use with vehicles; call llStopHover to cancel.
voidllStopHover()
Stops the hover behavior (such as that initiated by llSetHoverHeight).
voidllGroundRepel(float height, integer water, float tau)
Critically damps the object's vertical motion to height (using critical damping timescale tau) if it is within height * 0.5 of the terrain (or water level if water is TRUE). Only works on physics-enabled objects; do not use with vehicles.
voidllSetBuoyancy(float buoyancy)
Sets the buoyancy of a physical object (requires physics to be enabled). A value of 0.0 offers no buoyancy, < 1.0 sinks, 1.0 counteracts gravity, and > 1.0 rises.
vectorllGetVel()
Returns a vector representing the velocity of the object (in meters per second) relative to the global region coordinates. For physical objects, returns the velocity of its center of mass.
vectorllGetAccel()
Returns a vector representing the acceleration of the object in the region's frame of reference.
vectorllGetOmega()
Returns a vector representing the physical rotation (angular velocity) of the object in radians per second.
integerllTarget(vector position, float range)
Registers a positional target at position with a leeway radius range. This triggers at_target and not_at_target events. Returns an integer handle to unregister the target via llTargetRemove.
voidllTargetRemove(integer handle)
Removes the positional target specified by the integer handle registered with llTarget.
eventat_target(integer tnum, vector targetpos, vector ourpos)
Triggered when the scripted object's position (ourpos) comes within the defined range of the target position (targetpos) set by llTarget (which returns the associated handle tnum).
eventnot_at_target()
Triggered continuously while the object's position has not yet reached the range of targets set via llTarget.
integerllRotTarget(rotation rot, float error)
Registers the rotation rot with a leeway tolerance error (in radians) as a target, triggering at_rot_target and not_at_rot_target events. Returns an integer handle to unregister the target via llRotTargetRemove.
voidllRotTargetRemove(integer handle)
Removes the rotational target specified by the integer handle registered with llRotTarget.
eventat_rot_target(integer handle, rotation targetrot, rotation ourrot)
Triggered when the script's rotation (ourrot) comes within a defined angle (error) of the target rotation (targetrot) set by a call to llRotTarget (which returns the associated handle).
eventnot_at_rot_target()
Triggered continuously while the object's rotation is outside the leeway angle of targets set via llRotTarget.
eventmoving_start()
Triggered whenever the physical or moving object containing the script starts moving.
eventmoving_end()
Triggered whenever the physical or moving object containing the script stops moving.
voidllTargetOmega(vector axis, float spinrate, float gain)
Applies a smooth client-side rotation around the local axis at a rate equal to spinrate multiplied by the magnitude of axis (in radians per second) with a force defined by gain. Set spinrate to 0.0 to cancel.
voidllSetVehicleType(integer type)
Sets the vehicle physics preset type to one of the default vehicle types.
voidllSetVehicleFloatParam(integer param, float value)
Sets the specified vehicle float parameter param to value.
voidllSetVehicleVectorParam(integer param, vector vec)
Sets the specified vehicle vector parameter param to vec.
voidllSetVehicleRotationParam(integer param, rotation rot)
Sets the specified vehicle rotation parameter param to rot.
voidllSetVehicleFlags(integer flags)
Enables the vehicle flags specified in the Flags bitmask.
voidllRemoveVehicleFlags(integer flags)
Disables the specified vehicle flags (sets them to FALSE) using the bitwise mask flags.

Additional

Constant groups KeyframedMotionParam 3KeyframedMotionMode 4KeyframedMotionCommand 3KeyframedMotionData 2

See also Planned Recipe: door or platform with keyframed motion

Constant groups VehicleType 6VehicleFloatParam 17VehicleVectorParam 5VehicleRotationParam 1VehicleFlag 11

See also Category VehiclesSL Wiki LSL VehicleFeature InputFeature CameraFeature PathfindingSL Wiki Script library: vehiclesPage Guide: constraining rotationsPage Guide: turret rotation (a camera-following turret)Page Guide: interpolation and easing (stepping values towards a target)Planned Guide: tuning a vehicle

See also Feature Physics