Part 5+ Part 6: Shell Creation and Firing Shells

Well! Gamemakerlab guesses that you have done previously parts, right? So, You don't wait anymore. 

Certainly, we will guide how to create Shell Creation and Firing Shells by Unity which are parts of Tanks Game. 

In addition, we will divide Tanks game into several parts. By the way, you will feel comfortable to get affordable information.

Part 5 : Shell Creation

Finding Shell model on folder Models

  1. Drag itself into Hierachy
  2. Adding Capsule Collider component.
  3. Check Is trigger at Capsule Collider.
  4. Re-Establish Direction become Z-Asis
  5. Change the Center position of capsule collider to (0,0,0.2)
  6. Changes radius to 0.15 and Height to 0.55
  7. Finally,  adding Rigidbody component. 


Finding ShellExplosion prefab in folder Prefabs

  1. Drag  prefab on Shell GameObject.
  2. Add Audio Source  component so that adding sound for this prefab
  3. Finding and  select ShellExplosion in Audio Clip.
  4. Uncheck Play On Awake.


In Shell GameObject


  1. Add Light component in Shell GameObject.
  2. Finding ShellExplosion script at folder Scripts
  3. Dragging this script to Shell GameObject
  4. Adding code to script to accomplishing, Code could be taken from here
  5. At Tank Mask select Players.
  6. At  Explosion Particles and Explosion Audio, select ShellExplosion.
  7. Dragging Shell GameObject into folder Frefabs and save it



 Part 6 :  Firing Shells 

Select Tank GameObject


  1. Right mouse click at Tank GameObject and select at Create Empty
  2. Rename the created object to  FireTransform
  3. Establish the position of  FireTransform into  (0,1.7,1.35).
  4. Set the angle of  FireTransform into (350,0,0).


In Canvas of TanksGameObject

  1.  Create UI Slider and Rename to AimSlider
  2. Delete Background and Handle Slide Area at this section.

In AimSlider


  1. Uncheck Interable
  2. Establish Slider component Transition to none
  3. Establish Direction Bottom To Top
  4. Set the Min Value to 15
  5. Set the Max Value to 30


Select AimSlider and Fill Area GameObject


  1. In Rect Transform components,  click on the Anchor Presets and select alt-click the lower-right option to Stretch the GameObject vertically and horizontally over the canvas

  2. Expand Fill Area and select Fill
  3. Establish Height value by 5
  4. In  Image component, change Source Image to Aim Arrow




Back to AimSlider GameObject

  1. Establish Rect Transform (1,-9,-1,1,3).

Select TanksObject


  1. Find and drag TankShooting script into Tank GameObject. Repair code likely the link below
  2. On the section of TankShooting script, at the item of Shell component, find  Shell prefab on folder Prefabs and drag in
  3. Find FileTransform GameObject and drag in FireTransform
  4. Find AimSlider GameObject and drag in  AimSlider item
  5. Find the second Audio Source on the Tank GameObject. Drag into Shooting Audio
  6. At Charging clip item, select  ShotCharging
  7. At  the item of Fire Clip, select  ShotFiring
  8. Press Apply to applying Tank prefab and delete Tank GameObject on Hierarchy


 So, You complete Part 5 and 6 of Tanks Game Tutorials. In the next time, we will give the rest of it. Waiting to get more information.