October 2016
Beginner
506 pages
10h 1m
English
The player will select an attack and then select the enemy to perform the attack. To allow the player to select various attacks from the HUD, we will create a new script called Attack in the Assets/Scripts folder, as follows:
using UnityEngine;
using System.Collections;
public class Attack : MonoBehaviour {
public bool attackSelected=false;
public int hitAmount=0;
public void Smack(){
hitAmount=5;
AttackTheEnemy();
}
public void Wack(){
hitAmount=10;
AttackTheEnemy();
}
public void Kick(){
hitAmount=15;
AttackTheEnemy();
}
public void Chop(){
hitAmount=20;
AttackTheEnemy();
}
public void AttackTheEnemy(){
attackSelected=true;
}
}
Essentially, when each button is hit, it will reference a different attack with a different hit ...
Read now
Unlock full access