Part 7 and 8: Tanks Game Tutorial

In this tutorial, Gamemakerlab will give the rest of Tanks Game,

Do hope that you will create a Tanks Game by our guide. 

Part 7 : Game Managers                   

On the item of  Hierachy

  1. Press Create->Create Empty
  2. Rename into SpawPoint1
  3. Establish the position by (-3,0,30). Establish the angle by (0,180,0)
  4. Continuously, create  the Create Empty and rename into SpawPoint2
  5. Establish the position (13,0,-5) establish the angle (0,0,0)
  6. Create the UI->Canvas and rename into MessageCanvas.

On the item of MessageCanvas GameObject:

  1. Create the UI -> Text

On the item of MessageCanvas GameObject:

  1. At the Anchors component, establish the value of Min(0.1,0.1) and Max(0.9,0.9)
  2. Rect tranform component the value of (0,0,0,0,0)
  3. At the Text component, rename into TANKS! and format the font by BowlbyOne-Regular.
  4. Centered the Alignment
  5. Check Best Fit. Establish the value of min Size is 10 , max Size is 60. Color (255,255,255)

  6. Adding Shadow component
  7. At Shadow component, set up Color (114,71,40,128)

On the item of Hierachy

  1. Create the Create->Crate Empty
  2. Rename the created item into GameManage
  3. Find and drag GameManager script in GameManager GameObject
  4. Repair code likely the link below :

https://www.dropbox.com/s/jmw13cejer90i6t/GameManager.cs?dl=0

On the GameManager component of GameManager GameObject

  1. At the CameraControl,  we should drag the CameraRig to  the CameraControl
  2. At the MessageText, we select Text
  3. At the TankPrefab, we should the Tank prefab from Prefabs folder.
  4. Expand Tanks and set up size to 2.
  5. Adjust the color of the first component ( Element 0) by( 42, 100, 178) and drag SpawnPoint1 on Spawn Point
  6. Adjust the color of the second component( Element 1) by (229,46,40) and drag SpawPoint2 on Spawn Point
  7. Save scene and Play to test the result. 

 Part 8: Audio

#Create

  1. Select the GameManager -> GameObject, Adding the Audio component > Audio Source.
  2. Using “Circle- select” button to set Audio Clip as BackgroundMusic
  3. Check Loop

#Audio Mixer

  1. Right click on AudioMixers folder and select Create > Audio Mixer
  2. Rename created-file to MainMix
  3. Access to Window > Audio Mixer, you could drag this window and put it next to the window of Scene or expand itself to view by clearly.

# Mixer

  1. Using “ + icon” on Groups Card to adding a child component of the Master Group.
  2. New Group’s name is Music
  3. Do the same thing with Master to adding one child Group and named by SFX and the third Group will named Driving, All the three Group are Master’s children

# Add to Tank Prefab

  1. Select the Tank prefab on Prefabs folder
  2. For the first Audio Source, use circle-select button to set its Output  to the Driving group of the MainMix audio mixer

  3. For the second Audio Source,use circle-select button set its Output  to the Driving group of the MainMix audio mixer

 

# Add to Shell Prefab

  1. Finding  Shell Prefab on Prefabs folder, open it out and select the ShellExplosion (It is not the ShellExplosion outside)
  2. Set Output  Audio Source’s component as SFX on MainMix Audio Mixer

            

# Add to GameManager

1.       In the Hierarchy, we will select the GameManager GameObject. Then, select  Audio Source’s component and set  Music of MainMix

2.       Select  TankExplosion prefab on Project/Prefabs, set the value of  SFX group on MainMix audio mixer for  Audio Source Output of this prefab 

# Setting Value

1.       Back to Audio Mixer

2.       Make sure that MainMix was selected.

3.       Select  Music at the MainMix and Set the Attenuation to -12 by moving fader

4.       Do the same thing to setting Driving is -25

5.       Re- select  Music on the MainMix, On the window of Inspector, Click Add Effect button and select  Duck Volume

6.       Select  SFX on the MainMix, Click Add Effect button và select  Send

7.       At the Inspector, set Receive into Music\Duck Volume, Send Level is 0dB(full)


8.       Select  Music on the MainMix, At the Duck Volume on Inspector window, set Threshold by -46dB, Ratio 250%, Attack Time 0


9.       Save scene and Play

10.   Complete!

 

Congratulation ! You have completed Tanks Game by Unity. Now, Let enjoy result of your  effort.