Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Mastering Unity 2D game development
  • Toc
  • feedback
Mastering Unity 2D game development

Mastering Unity 2D game development

By : Jackson
3.8 (21)
close
Mastering Unity 2D game development

Mastering Unity 2D game development

3.8 (21)
By: Jackson

Overview of this book

If you have C# knowledge but now want to become truly confident in creating fully functional 2D RPG games with Unity, then this book will show you everything you need to know.
Table of Contents (15 chapters)
close
Free Chapter
1
1. Overview
14
Index

Putting it together

Following on from the previous chapter, we will continue on our journey of the battle and kick off with some target practice.

Preparing the BattleManager script

As we prepare to attack our foe, we recognize that the player can only target one Goblin at a time with his trusty sword or axe (there could be some splash damage or knock - on attack later, but let's focus on our player's attack first). So, we'll add some variables to BattleManager to manage this.

We will also add some other elements to spruce up the battle, such as a selection circle or a target identifier, and add a variable to set a prefab for this.

So, open the BattleManager script and add the following variables to the top of the class:

private string selectedTargetName;
private EnemyController selectedTarget;
public GameObject selectionCircle;
private bool canSelectEnemy;

bool attacking = false;

public bool CanSelectEnemy
{
  get
  {
    return canSelectEnemy;
  }
}

public int EnemyCount
...
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete