Part 3 + part 4: Health

Welcome back gamemakerlab tutorial! 

Today, we will give part 3 and 4 of Tank tutorial. In previously part, Gamemakerlab guide you how to create and set up Projects.

Gamemakerlab hopes that you could make it well. Now, we will make next steps to complete this game.

Part 3:

  1. Create a Empty Object on Hierarchy’s window and name is CameraRig
  2. Reset Position’s parameters of CameraRig by clicking on the gear setting in the Position select reset
  3. Assign the value of the Camera Rig Rotation of (40, 60, 0)
  4. In the Hierarchy drag Main Camera Camera Rig into a child of CameraRig
  5. Assign Postion Main Camera (0, 0, -65), Rotation (0, 0, 0)

#Script

  1. Search script CameraControl on folder Script/Camera
  2. Drag and drop on CameraRig
  3. Open script by double clicking itself

You could repair code likely code on below link:

https://www.dropbox.com/s/urzszy6ptx697xr/CameraControl.cs?dl=0

This script’s task:

  1. Finding position of Tank GameObject
  2. Establish the position of CameraRig to have overall view

Part 4: Health

#Create

  1. At Hierachy panel, click Create > UI> Slider
  2. At Event System, changes Horizonatal Axis into HorizontalUI, change Vertical Axis into VerticalUI
  3. Click on Canavas, At Canavas Scaler, change Reference Pixels per Unit into 1
  4. At Canvas change Render Scale Mode to World Space

          

# Setting

  1. On  Hierachy Drag ana drop Canvas onto Tank GameObject
  2. Click Canvas, on Rect Transform, change Position to (0,0.1,0)
  3. Change Width and  Height to 3.5
  4. Change Rotation to (90,0,0)
  5. Save Scene .

# Create Slider

        

#Slider setting

  1. Click on  Slider and  uncheck Interactable
  2. Change Transition to None
  3. Change  Max Value and Value to 100

         

# Background

  1. Rename Slider to HealthSlider
  2. Click on Background GameObject, on  Image panel,  use the button of circle shape to chaging  Source Image to HealthWheel
  3. At Color change Alpha(a) to 80

        

# Fill

  1. Click on Fill GameObject, Change Source Image to HealthWheel and set Alpha(a) become 150
  2. Change  Image Type to Filled, also change Fill Origin to Left
  3. Unselect Clickwise

        

 

# Script

  1. Adding script UIDirectionControl at Scripts/UI onto HealthSlider
  2. Click on Tank GameObject and Apply to update new property onto Prefabs

# Tank Explosion

  1. At file Prefabs drag and drop TankExplosion vào Hierarchy
  2. Adding Audio Source to TankExplosion
  3. At Audio Source, Assign TankExplosion Clip vào AudioClip và unselect Play On Wake
  4. At  TankExplosion GameObject, click Apply to updating Prefab
  5. Delete TankExplosion on Hierarchy
  6. Adding script TankHealth on Scripts/Tank to Tank GameObject by dragging dropping to  Tanks GameObject
  7. Double-click at TankHealth

You could repair code likely code on below link:

https://www.dropbox.com/s/yuaos6blcztards/TankHealth.cs?dl=0

This Code conduct:

  1. Establish Tank Damage
  2. Update health blood
  3. Stopping Tank’s operation.

# Script setting

  1. Select Tank GameObject
  2. Drag ang drop HealthSlider GameObject from Hierarchy to HealthSlider of script TankHealth
  3. Do the same thing with Fill GameObject and apply on  Fill Image
  4. Drag and Drop TankExplosion  on  Prefabs folder at Explosion Prefab
  5. Click Apply  at Tank GameObject to updating Tank Prefab
  6. Save Scene

            

 

In the next post, gamemaker will guide to make the rest of game. Don't forget to get more information by sign up our website or follow Fanpage at :

website:  http://gamemakerlab.com/
fanpage: https://www.facebook.com/gamemakerlab/?ref=ts&fref=ts

If you have any question, don't hesitate to contact us.