The Body Mesh Template allows you to apply effects to the body that automatically fits the Snapchatter. The template comes with both an example of applying textures to a Body Mesh, as well as using the body mesh as placeholders to drive effects, such as tapping to instantiate on parts of the body.
This is the documentation page for the
Body Mesh Template in Lens Studio. In this guide we’ll cover:
- Sci-fi Suits - Using the Body Mesh UV and 3D Objects as references
- Growing Vine- Mapping 3D objects on top of the Body Mesh
- Move Along Body- Making a path along the Body Mesh for objects to follow
- Tap To Add- Tapping on the body to append objects to it
- Instantiate Objects - Instantiate one object all across the Body Mesh
Let’s get started!
Tip: See how you can simply attach things to the Body Mesh, as well as Download the Body Mesh 3D Model and UV reference in the Body Mesh Guide!
The Body Mesh Template comes with examples of 2
Body Mesh components in the scene. Each of them have a 3D belt object attached to the waist. Feel free to check it out and see how you can attach 3D objects to the body with the
To check out more custom materials you can use with the Body Mesh, feel free to swap these materials with any inside the
Materials folder titled
Now we know we can use
PinToMesh to attach objects to the body. We can use this with any rigged 3D objects to wrap them around the body!
To achieve this effect, we will have our object rigged inside a 3D program. To have an easier time pinning rotation to the body we can just set all the bones to have
0 rotation on them.
Then we’ll bring it to Lens Studio, and apply
PinToMesh to all the bones, then drag them each to a desired position.
Make sure to set the
Orientation property to
OnlyPosition (because we set all the bones to
vertical earlier). Then your object will ‘attach’ to the Body Mesh.
Move Along Body
This setup allows you to move an object along the Body Mesh with an adjustable path.
PathParent object you’ll find a list of objects all with the
PinToMesh property that’s attached to the
The movement of fish in this example is controlled by the
MoveAlongPinnedMesh script attached to the
Move On Body object
Tip: Try changing
Move Type from
Ping Pong to
Move Once to experiment with different types of looping of the moving target.
Tip: Turn on
Debug Mode to see all the target positions which are used to form the path for the moving target object.
Tap To Add
Tap To Add example uses the
TapToAdd script to let users add random objects from an array to the body mesh when they tap the mesh.
TapToAdd script takes the
uvSampler render target as a texture input, and gets the pixel color of the render target texture from
UVSampler based on screen tapped position. The pixel color is determined by the material
renderUV applied to the
Body Mesh_GENERATE_UV object.
To see what the
uvSampler render target looks like, we can quickly create a screen image with the
uvSampler as a texture.
In addition, we can see in the
renderUV material, the color is determined in a way that uv x position determines the red channel and y position determines the green channel of main color of the material.
uvSampler script, once it gets the pixel color of tapped position, it can then use this color to determine the UV position of the body, and use that with the
PinToMesh component to attach objects to the body when tapped.
Right click to highlight the flower prefabs and you’ll see each of them have a
PinToMesh component. The script will set their target to the
TargetMesh variable (in this case it is the Body Mesh object) and set the pinned position to converted UV position on tap.
Try replacing prefabs in the
PinAsset array to create your own items to be generated when body is tapped!
The Instance example allows you to spawn instances of objects along the body based on predetermined UV positions with
Everything under the
InstanceObj_EDIT_ME object will be duplicated along the body. Try toggling different objects inside this object or add your own!
InstantiateObjectsOnMesh script uses Reference Points under the
ReferencePoints object to generate positions on the
Body Mesh. It is categorized into front, back and inner (places in-between legs and arms and body) points.
Feel free to toggle the
AddBackPoints variables to see how it changes the scene!
Previewing Your Lens
You’re now ready to preview your Lens! To preview your Lens in Snapchat, follow the Pairing to Snapchat guide.
Please refer to the guides below for additional information:
Still Looking for help?Visit Support