PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

TextureMode

Trail

TextureMode

A Trail's TextureMode property determines how the effect’s Trail/Texture (if any) is drawn. The behavior of the texture in each mode is also very much dependent on the effect’s Trail/TextureLength property. Note that changing an effect’s TextureMode after some of the trail has been drawn will affect all of the previously drawn segments.

TextureMode defaults to Stretch

##Stretch
Stretch is the default TextureMode for Trails. In this mode the texture will be tiled a number of times equal to the number defined by TextureLength. It will stretch these tiles evenly to fit the entire length of the drawn trail. For example, if TextureLength is set to 4 then the texture will always repeat 4 times in the trail, no matter how long or short the trail is.

Demonstrating a trail texture using the stretch mode.

##Wrap
In the Wrap mode, the texture will start at the attachment points and will move as the attachments move. As soon as the attachments have moved a number of studs equal to the TextureLength, then the texture will repeat. The longer the trail is, the more times the texture will repeat.

Demonstrating a trail texture using the wrap mode.

##Static
In the Static mode, the texture will start at the initial position of the trail and will be drawn as the attachments move. Once the attachments move a number of studs equal to the TextureLength, then the texture will repeat.

Demonstrating a trail texture using the static mode.


Code Samples


Setting a Trail's Texture Mode

This example demos setting a trail’s texture mode.

In order to do this, we must first create a BasePart, part, which will be the parent of the trail.

Then, we create two attachments, attachment0 and attachment1, both parented to part. The positions of these two attachments, more importantly the distance between them, determines where the trail is drawn as part moves.

For these attachments to create a trail as described, we create a new Trail and parent it to part. We then connect attachment0 to Trail/Attachment0 and attachment1 to Trail/Attachment1.

In this example, we set the trail’s texture mode to static. Note that this is just one of three possible modes, and that the example below can easily be changed to use another mode. We also set the texture of the trail to a pawprint image.

Finally, to demo the texture mode the example relies on TweenService's TweenService/Create to move part back and forth. As the part moves, the trail is drawn.

Demonstrating the static trail texture mode.