Create a Text Path with Bezier Spline in Unity
14 steps to prepare necessary files and create a moving string of 3D text in Unity
Scripts required: Bezier Spline, Spline walker array
VIMEO link: https://vimeo.com/726391996
Step by step (preparation):
- Start by downloading the project files from Catlike Coding with this link, extract them, and put them in respective folders.
- Ensure you have the Oculus Integration package (full instructions here).
- Use the search bar in Unity to find the OVR Player Controller and drag it to the project hierarchy menu (skip steps 2 & 3 if it’s already in your menu).
- Set up your scene as desired, remember to include a camera if using for VR.
- To prevent the camera from falling out of the scene, create a 3D plane and uncheck the mesh renderer option in the plane inspector. Size and position the plane as desired.
Step by step (create the path):
- Create two empty game objects and a 3D text object (fig. 1); Rename them with descriptive titles and select reset in all of their transform menus (fig. 2).
- In the text object’s transform menu, reduce the scale to 0.1 or 0.01.
- Select the empty game object you wish to use for the path. Click Add Component in the object inspector, select the Bezier Spline script (fig. 3).
- Press F to create the line. Adjust the line by dragging the points. Add more points to the line by clicking add curve in the Bezier Spline menu (fig. 4).
- Next, select the empty game object reserved for the Spline walker array and select the appropriate script in the object inspector.
- Click and drag the path game object from the hierarchy menu to the Spline field in the Spline walker array script menu (fig. 5).
- Also in the Spline walker array script menu, enter a numerical value for the movement duration (this can be adjusted later) and change the mode to loop.
- Click and drag the 3D text object from the hierarchy menu to the selector field in the Spline walker array script menu.
- Click the play button at the top of the window to see the animation. Adjust the text appearance under text mesh in the 3D text object inspector as desired.
Creating 3D text object
Resetting game objects and 3D text object
Adding Bezier Spline script to the empty game object
Adding more points to the line
Dragging the path object to the Spline field
- If text is appearing lo-res, try increasing the font size in the 3D text object’s text mesh menu and decreasing character size or the scale in the transform menu.
- The moving text being displayed can be edited by opening the Spline walker array script and editing the string sentence comment. See video instructions