Part 2: Tanks Creation

Part 2: Tanks Creation

Tank Creation

1. Into Models folder of Project, find model Tank and drag it into Hierarchy

2. At the top of Inspector, set Layer of Tank as Players 

3. Into Change Layer Box , select “No, this object only”

Rigidbody

1. Adding the Rigidbody component to the Physics

2. Expanding the Constraints of  the Rigidbody

3. Into Constraints Freeze Position select Y axis 

4. Into Constraints Freeze Rotation select X,Z axis 

At here, we will freeze Position follow Y axis. It means that Object couldn’t go up and down. Beside that it will be freeze follow 2 axis: X and Z axis.

 

Collider

1. Adding  a Box Collider component to the Tank GameObject 

2. On the Box Collider component change the Center to ( 0, 0.85, 0 ) 

3. Also, change the Size to ( 1.5, 1.7, 1.6 )

Audio Source 1

1. Adding a Audio Source component to the Tank GameObject.

2. On Audio Source component, we will change the AudioClip to EngineIdle using the circle-select button 

3. Check  Loop to repeat audio

Audio Source 2

1. Adding the other Audio Source component

2. On  the second Audio Source component, we will uncheck the Play On Awake 

3. Select  Prefabs folder in the Project panel 

4. Click to drag Tank GameObject from Hierarchy to Prefabs

5. Save  scene

 

Dust Trail

1. Into Trong folder Prefabs drag the DustTrail prefab onto the Tank GameObject in the Hierarchy to make it a child GameObject .

2. Duplicate the DustTrail by use Command-D on Mac or Ctrl-D on PC

3. Rename one of  DustTrails to LeftDustTrail 

4. Set Position of the LeftDustTrail to ( -0.5, 0, -0.75 ) 

5. Rename the other DustTrail to RightDustTrail 

6. Set  Position of  RightDustTrail to ( 0.5, 0, -0.75 )

Moving

1. Into folder Scripts/Tank, find TankMovement script

2. Drag and drop it onto theTank GameObject 

3. Open TankMovement script by double click onto Script 0 

 

Checklist of this script includes:

1. get the Input

2. set up the audio

3. set up the moving( forward/ back)

4. Set up turning 

You could repair code likely code on below link: https://www.dropbox.com/s/2kbqwpl2vtb36vt/TankMovement.cs?dl=0

 

# Setting code

1. Drag and drop the first Audio Source component of Tank GameObject to the Movement Audio

2. Select EngineIdle for Engine Idling by using the beside circle- button 

3. Do the same thing, select EngineDriving for  Engine Driving

4. On the top of Inspector, we should select Apply to apply properties into Prefabs 

5. Save Scene