"How to make a Track Belt" (Ver.1.1)

Please feel free to contact me if you have any questions.
shopmaster@chobi-glass.com
http://chobi-glass.com/Unity/index.html


This tutorial shows how to make and set up track belts in the tank.
The mesh for track belt can be created by using 3D modeling tools or "Create_Tracks_CS" script in this project.
In this tutorial, we will create the mesh with using "Create_Tracks_CS" script.

This tutorial uses a new tank made in the previous tutorial "How to make a new tank".


(1) Prepare "Create_Tracks_CS" script.
    When you have a new tank made in the previous tutorial, the script is already prepared in the "Track_Belt_L" in the tank. Please progress to the next step.
    When your tank is made by remodeling other tank prefab, remove the old "Track_Belt_L" and "Track_Belt_R", and set a new "Track_Belt_L" into the tank.
        You can find the prefab "Track_Belt_L" in the "Tank_Components" folder under the "Prefabs" folder. Drag and drop it into the "MainBody" in the Hierarchy window.
        And make sure that the "Track_Belt_L" is placed under the "MainBody" as the child.
       


(2) Set the Material.
    At first, set the Material for the track belt into the Mesh Renderer.
    In this tutorial, set the Material as follows.
   


(3) Create the Mesh.
    Press the "Get Default Settings" button in the "Create_Tracks_CS".
    And make sure that the basic mesh has been created.
   
    The shape of the mesh is formed by referring to the wheels in the tank. But it is not perfect.
    You need to fix the shape by adjusting each "Radius", "Start Angle" and "End Angle".
    Also fix the position and the size by adjusting the "Position X", "Width" and "Height".
    In this tutorial, set the values as follows.
   
   
    Now, the mesh has been finished. Next, let's set up the UV map.


(4) Set up the UV map.
    Set the V axis values for each corner of the mesh into the "Line #". Also set the "Scale" value for U axis.
    The texture is scrolled along U axis. Adjust the "Scale" value so that the pattern is displayed with proper proportion.
    And adjust  "Line A-H" values to set up the mapping on V axis. Each line corresponds to each corner as follows.

   
    (Tip.) You can see the t exture and guide lines by enabling the "Show Texture" option.

    In this tutorial, set the values as follows.
   
   
    Now, the track belt has got the texture. Let's set up the scrolling and deforming settings in the following steps.
   

(5) Set up the "Track_Scroll_CS".
    The scrolling is controlled by "Track_Scroll_CS" script referring to the rotation speed of the "Reference Wheel".
    Press the "Find RoadWheel [ Left ]" button, and make sure that the "Reference Wheel" is set automatically.
   
    Also you need to adjust the "Scroll Rate" value so that the texture moves synchronizing with rotation of the wheels.
    Please find the appropriate value while driving the tank, after the track belt is completed.

    In this tutorial, set the value to "0.0005" temporarily.


(6) Set up the "Track_Deform_CS".
    The deforming is controlled by "Track_Deform_CS" script referring to the positions of the "Anchor Wheels".
    Press the "Find RoadWheels [ Left ]" button, and make sure each "Anchor Wheel" is set automatically.
   
    The vertices within the green square are moved according with the "Anchor Wheel".
    You can fix the range by adjusting the "Weight Width""Weight_Height" and "Offset" values.
   
    In this tutorial, you need not change them.


(7) Test the behavior.
    Test the behavior while driving the tank in the runtime.
    Make sure that the mesh deforms according to the terrain, and the texture scrolls according to the speed.


(8) Create the right one.
    Create the right track belt in the following steps.
        Duplicate the "Track_Belt_L", and rename it to "Track_Belt_R".
        Uncheck the "Left" option in the "Create_Tracks_CS".
        Press the "Find RoadWheel [ Right ]" button in the "Track_Scroll_CS".
        Press the "Find RoadWheels [ Right ]" button in the "Track_Deform_CS".
    And test it in the runtime.


(9) Save the meshes.
    The meshes are just temporary data now. You need to save the meshes to use them in other scenes.
    Press the "Save New Mesh" button in the "Create_Tracks_CS" in each track belt (left and right).
    And make sure that the new assets are created in the "User" folder.
   


(10) Set up the "Culling_Control_CS".
    The tank has a culling function to improve the performance.
    Select the "MainBody" in the tank, and set up the "Culling_Control_CS" script in it.
   
    This script disable the "Track_Deform_CS" and "Track_Scroll_CS" scripts in the both tracks according to the distance from the main camera.
    Drag and drop the tracks into each box.


(11) You have now completed the tutorial "How to make a Track Belt".
    Create a new prefab of your tank to use it in other scenes.
    Your tank is almost completed now. Let's set up the Armor and Sound settings for it.
    Please progress to the next tutorial "How to set up Armor and Sound".



Please feel free to contact me if you have any questions.
shopmaster@chobi-glass.com
http://chobi-glass.com/Unity/index.html