LlSetTextureAnim
Looking for the current API? Open the llSetTextureAnim reference →
Wiki description
Animate the texture on the specified face/faces by setting the texture scale and offset.
Function notes
Frames are numbered from left to right, top to bottom, starting at 0.
If
If
If
rate is negative, it has the same effect as using the REVERSE flag.Though if rate is negative and the REVERSE flag is used, they cancel each other out.If
length is 0, it is considered to be sizex*sizey if both are above 0, otherwise 1.Specification
Frames
Frames are sub-rectangles within the texture. A set of frames with 2 horizontal (
sizex) and 3 vertical (sizey) means the overall texture is divided into 3 rows of 2 columns of images, each of which is a frame. llSetTextureAnim will animate across these 6 starting with the top left image and going across and down, optionally repeating. If SMOOTH is set, the frames slide smoothly from one to the next across each row but will "jump" from one row to the next, if off, each frame is displayed in turn centered on the face.| Modes | Description | |
|---|---|---|
| ANIM_ON | 1 | Texture animation is on. This must be set to start the animation, cleared to stop it. |
| LOOP | 2 | Loop the texture animation. |
| REVERSE | 4 | Play animation in reverse direction. |
| PING_PONG | 8 | Play animation going forwards, then backwards. |
| SMOOTH | 16 | Slide in the X direction, instead of playing separate frames. In both SCALE and ROTATE modes, causes smooth transitions. |
| ROTATE | 32 | Animate texture rotation. Does not work with SCALE |
| SCALE | 64 | Animate the texture scale. Does not work with ROTATE |
Caveats
- You can only have one texture animation on a prim.
- Calling llSetTextureAnim more than once on a prim will reset the existing animation.
- Calling llSetTextureAnim again with exact same values will not reset animation (a small difference in rate will suffice).
- You cannot combine ROTATE and SCALE flags.
sizexandsizeyare both limited to a range of 0 to 255.- Negative sizes behave as if texture repeats were set to 0, and cannot be used to mirror frames.
- Different animation modes override some of the prim's texture parameters, but others can still be used:
- Texture offsets are ignored in frame-based and SMOOTH scrolling modes.
- Repeats are ignored if
sizexandsizeyare not 0. - With either of the sizes set to 0, SMOOTH scrolling will use the prim's texture repeats. In frame-based animation, there is no meaningful effect.
- Repeats are ignored if
- The texture rotation is ignored in ROTATE mode.
- Texture repeats are ignored in SCALE mode.
- Texture offsets are ignored in frame-based and SMOOTH scrolling modes.
- An animation using only SMOOTH without LOOP behaves poorly, whether scrolling, rotating or scaling. The animation timing is based on the object's time of existence for the viewer, so a non-looped SMOOTH animation may not play at all if the object time is out of bounds for the specified start/end, and attempting to replay it after it has stopped has no effect.
- Playing a SMOOTH animation backwards may loop even if not told to do so, and will "rewind" the internal timer allowing it to play forwards afterwards, possibly longer than what the parameters specified suggest.
- Selecting and un-selecting a prim with animation will reset animation from beginning.
- While a texture animation is active on any face of a prim, PRIM_NORMAL and PRIM_SPECULAR are usually forced to have their repeats, rotations and offsets to match the PRIM_TEXTURE ones, even on faces that are not being animated. Non-animated PBR textured faces are unaffected by this limitation.
- As of server version 2025-09-03.17442317385, this prim property is maintained when copying in-world.
Examples
This slides a texture smoothly, along the horizontal U-axis, and loops it when it gets to the end.
For Blinn-Phong materials, the texture's rotation for each side affects the apparent motion. So if the texture is rotated 90 degrees by use of the edit box, the texture may not flow in the direction expected.
For PBR materials, the Blinn-Phong texture rotation for each side affects the apparent motion, and any Blinn-Phong transform component (for example the offsets argument of PRIM_TEXTURE) which is not animated will be applied to the PBR material as well. Thus, a GLTF material without a GLTF texture transform will animate identically to a Blinn-Phong material. If a GLTF texture transform (for example PRIM_GLTF_BASE_COLOR) is applied, it will be in addition to the Blinn-Phong transform and texture animation. This allows for more flexibility; however, a more complex GLTF texture transform will not loop as easily.
llSetTextureAnim(ANIM_ON | SMOOTH | LOOP , ALL_SIDES, 1, 1, 1.0, 1.0, 1.0);This slides a texture smoothly, along the horizontal U-axis, in the opposite direction.
llSetTextureAnim(ANIM_ON | SMOOTH | LOOP , ALL_SIDES, 1, 1, 1.0, 1.0, -1.0);This divides a texture into 64 "cells", 8 across, and 8 down, and flips through them, left to right, top to bottom. This is useful for cell animation.
llSetTextureAnim( ANIM_ON | LOOP, ALL_SIDES, 8, 8, 0.0, 64.0, 6.4 );This rotates a texture counter-clockwise at 2 revolutions per second. Change the last value to -2*TWO_PI to rotate clockwise.
llSetTextureAnim(ANIM_ON | SMOOTH | ROTATE | LOOP, ALL_SIDES,1,1,0, TWO_PI, 2*TWO_PI);This scales a texture larger and smaller.
llSetTextureAnim(ANIM_ON | SMOOTH | SCALE | PING_PONG | LOOP, ALL_SIDES, 1, 1, 1.0, 3.0, 2.0);This turns off all texture animations.
llSetTextureAnim(FALSE, ALL_SIDES, 0, 0, 0.0, 0.0, 1.0);This toggles a looping animation to make it stop at a specific frame.
integer textureIsBeingAnimated;
default
{
touch_start(integer num_detected)
{
if (textureIsBeingAnimated)
llSetTextureAnim(ANIM_ON | LOOP, ALL_SIDES, 1, 5, 0.0, 0.0, 1.0);
else
llSetTextureAnim(ANIM_ON | SMOOTH, ALL_SIDES, 1, 5, 5.0, 1.0, 1.0);
// toggle back and forth between TRUE (1) and FALSE (0)
textureIsBeingAnimated = !textureIsBeingAnimated;
}
}Notes
Texture animation is a property of the prim (i.e., you can remove the script that started the animation, and the prim will remember the settings anyway.)
See also: functions
History
Added in SL 0.4.0
Shared wiki helpers
The original page also injects shared parameter notes, caveats or issue information through these helpers. Their conditional MediaWiki logic is not reproduced here; inspect the preserved helper source for additional material.
Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|SVC-4897|'''llSetSyncTime'''() - a function for synchronising client side effects|type=nf}}Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|SVC-3925|Some persistent prim properties lost when duplicated|type=bug}}Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|SVC-1242|Texture Animation is not copied (llSetTextureAnim)|type=bug}}Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|VWR-4018|[[llSetTextureAnim|Texture animations]] ignore repeats per [[face]]|type=bug}}Original shared helper source (conditional wiki logic is not evaluated)
{{LSL Injection Test}}{{#if:
{{#vardefine:header|{{#var:header}}{{#if:{{{nc|}}}{{#pos:{{#var:moded}}|r}}||{{#switch:{{NAMESPACE}}|Template=|User=|[[Category:LSL Face{{#var:lang}}]][[Category:LSL Face{{#var:lang}}/{{#if:{{{return|}}}{{{returns|}}}|Get|Set}}]]}}}}}}
{{#vardefine:ALL_SIDES|{{LSL Const|ALL_SIDES|integer|-1|hex=0xFFFFFFFF}}}}
{{#vardefine:p_{{{1|none}}}_desc|{{LSLGC|Face{{#var:lang}}|face}} number{{#ifeq:{{{notall|}}}|*||<nowiki> </nowiki>or {{#var:ALL_SIDES}}}}}}
{{#vardefine:p_{{{1|none}}}_hover|face number{{#ifeq:{{{notall|}}}|*||<nowiki> </nowiki>or ALL_SIDES (-1)}}}}
{{#ifeq:{{{notall|}}}|*||{{#vardefine:facechoise|If {{LSLP|{{{1|none}}}}} is {{#var:ALL_SIDES}} then the {{#if:{{{2|}}}|{{{2|}}}|function}} {{#if:{{{get|}}}|{{{get|}}}|{{#if:{{{ALL_SIDES|}}}|{{{ALL_SIDES|}}}|works on all sides.}}}}}}}}
{{#vardefine:header_footnote|{{#var:header_footnote}}{{#if:{{{!footer|}}}||{{PBR}}
{{#var:facechoise}}{{PBR}}}}}}
{{#vardefine:caveats|{{#var:caveats}}{{#if:{{{!footer|}}}|
*{{#var:facechoise}}|}}{{#if:{{{return|}}}{{{returns|}}}|
*If {{LSLP|{{{1|none}}}}} indicates a face that does not exist the {{#if:{{{2|}}}|{{{2|}}}}} {{#if:{{{return|}}}|return is {{{return|}}}| returns {{{returns|}}}}}|
*The {{#if:{{{2|}}}|{{{2|}}}|function}} silently fails if its {{LSLP|{{{1|none}}}}} value indicates a face that does not exist.}}}}
}}<noinclude>
{| {{Prettytable}}
|-{{Hl2}}
! #var
! value
|-
{{VarPair|ALL_SIDES}}
|-
{{VarPair|p_{{{1|none}}}_desc}}
|-
{{VarPair|p_{{{1|none}}}_hover}}
|-
{{VarPair|facechoise}}
|-
{{VarPair|header_footnote}}
|-
{{VarPair|caveats}}
|}
</noinclude>Template:LSL Function/negative index
Original shared helper source (conditional wiki logic is not evaluated)
{{LSL Injection Test}}<noinclude>
Format:
<nowiki>{{LSL Function/negative index|boolean|p1|p2|p3}}</nowiki><br/>
Exclude p1, p2, or p3 if not used.
{{#vardefine:also_articles|{{LSL DefineRow||Test}}}}
{{#vardefine:ni_mode|true}}
{{#vardefine:ni_nc|}}
{{#vardefine:ni_p1|number}}
{{#vardefine:ni_p2|p2}}
<!--{{#vardefine:ni_p3|p3}}-->
</noinclude>{{#if:
{{#vardefine:ni_c|{{#if:{{{2|{{#var:ni_p1}}}}}|{{#if:{{{3|{{#var:ni_p2}}}}}|{{#if:{{{4|{{#var:ni_p3}}}}}|3|2}}|1}}|0}}}}
{{#vardefine:t|{{#ifeq:{{{1|{{#var:ni_mode}}}}}|true|{{#switch:{{#var:ni_c}}|3|2=LSL_Function/negative_index/range|1=LSL_Function/negative_index/single}}}}}}
{{{{#var:t}}|{{{2|{{#var:ni_p1}}}}}|{{{3|{{#var:ni_p2}}}}}|{{{4|{{#var:ni_p3}}}}}|noExclude={{{noExclude|}}}}}
{{#if:{{{noSpec|}}}||
{{#vardefine:spec|{{#var:spec}}
{{#if:{{#var:t}}|
{{{!}} {{Prettytable|style=float:left;}}
{{!}}-{{Hl2}}
! Index
! Positive
! Negative
{{!}}-
{{!}} First
{{!}} <code>0</code>
{{!}} <code>-{{{length|length}}}</code>
{{!}}-
{{!}} Last
{{!}} <code>{{{length|length}}} - 1</code>
{{!}} <code>-1</code>
{{!}}}
=== Indexes ===
<div style="display:table;"><div style="display:block;">
*Positive indexes count from the beginning, the first item being indexed as <code>0</code>, the last as <code>({{{length|length}}} - 1)</code>.
</div></div>
<div style="display:table;"><div style="display:block;">
*Negative indexes count from the far end, the first item being indexed as <code>-{{{length|length}}}</code>, the last as <code>-1</code>.
</div></div>
}}
}}
}}
{{#vardefine:also_articles|{{#var:also_articles}}
{{#if:{{#var:t}}|{{LSL_DefineRow||{{LSLGC|Negative_Index{{#var:lang}}|Negative Index}}|}}}}}}
{{#vardefine:header_footnote|{{#var:header_footnote}}{{PBR}}
{{#vardefineecho:ni_ps|{{#switch:{{#var:ni_c}}
|0=This function
|1={{LSLP|{{{2}}}}}
|2={{LSLP|{{{2}}}}} & {{LSLP|{{{3}}}}}
|3={{LSLP|{{{2}}}}}, {{LSLP|{{{3}}}}} & {{LSLP|{{{4}}}}}
}}}} {{#if:{{#var:t}}| support{{#ifexpr:{{#var:ni_c}}>1||s}}| ''do{{#ifexpr:{{#var:ni_c}}>1||es}} not'' support }} {{LSLGC|Negative_Index{{#var:lang}}|negative indexes}}.{{PBR}}
}}
{{#vardefine:footer|{{#var:footer}}
{{#if:{{#var:t}}|{{#ifeq:{{NAMESPACE}}|Template||{{#if:{{#var:self}}{{{self|}}}{{#pos:{{#var:moded}}|r}}{{#pos:{{#var:moded}}|u}}||{{LSLC|Negative Index{{#var:lang}}}}}}}}|
{{#if:{{#var:self}}{{{self|}}}{{#pos:{{#var:moded}}|r}}{{#pos:{{#var:moded}}|u}}||{{LSLC|Positive_Index_Only{{#var:lang}}}}}}
}}}}
{{#vardefine:caveats|{{#var:caveats}}
{{#if:{{{nc|{{#var:ni_nc}}}}}||
* If {{#switch:{{#var:ni_c}}
|3=either {{LSLP|{{{2}}}}}, {{LSLP|{{{3}}}}} or {{LSLP|{{{4}}}}} are
|2=either {{LSLP|{{{2}}}}} or {{LSLP|{{{3}}}}} are
|1={{LSLP|{{{2}}}}} is}} out of bounds {{#if:{{{oob-return|}}}|this function returns {{{oob-return|}}} and}} the script continues to execute without an error message.
{{#if:{{#var:t}}|{{#ifexpr:{{#var:ni_c}}>1|{{#if:{{{noExclude|}}}|* {{LSLP|{{{2}}}}} & {{LSLP|{{{3}}}}} will not form an [[#exclusion_range|exclusion range]] when {{LSLP|{{{2}}}}} is past {{LSLP|{{{3}}}}} (Approximately: {{LSLP|{{{2}}}}} > {{LSLP|{{{3}}}}}), instead it will act as if {{LSLP|{{{2}}}}} was zero & {{LSLP|{{{3}}}}} was -1.|* {{LSLP|{{{2}}}}} & {{LSLP|{{{3}}}}} will form an [[#exclusion_range|exclusion range]] when {{LSLP|{{{2}}}}} is past {{LSLP|{{{3}}}}} (Approximately: {{LSLP|{{{2}}}}} > {{LSLP|{{{3}}}}}). }}}}}}
}}}}
}}<noinclude>
==Debugging==
{| {{Prettytable}}
|-{{Hl2}}
! #var
! value
|-
{{VarPair|header_footnote}}
|-
{{VarPair|spec}}
|-
{{VarPair|caveats}}
|-
{{VarPair|notes}}
|-
{{VarPair|constants_nb}}
|-
{{VarPairTable|also_articles}}
|-
{{VarPair|footer}}
|}
</noinclude>Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.