In this video, Jesse Freeman will teach you how to clean up the RPG’s battle system. You’ll learn how to randomly decide if the monster should attack the player first in battle to help balance out the battle loop. You’ll also lay in the ground work for messaging to the player when they enter a town or a castle since they are safe from random battles in the tile map.
- [Voiceover] Now it's time for us to…clean up our battle system.…Let's go ahead and open up the battle window.…The first thing we're going to do is test to see…whether the monster or the player should attack first.…Let's scroll down to our StartBattle method.…Right before we display the message,…let's set the value of nextActionPlayer to equal…rand.NextDouble() >= .5.…
Then we'll test to see if nextActionPlayer equals true.…If it's the player, we're going to display our message…that a monster is approaching.…If not, we'll create an else condition and…let's copy our Display message, paste it and instead…let's replace this to say monster.name…and where we have "approaches", "attacks first".…Now we can go and test this out.…We'll save our code, and go back into Unity.…
Now if we start a battle, we have a 50/50 shot…at who begins the battle.…Looks like a Slime approaches, so the player gets to…attack first.…Let's restart the battle until…we see the monster attacks first.…And we now know that this works.…This will help balance out the battles a little bit,…
- Preparing the user interface
- Creating game and message windows
- Building a battle window
- Adding a monster and action buttons
- Creating an actor class
- Adding player and monster attack actions
- Triggering battles from the map
- Ending a battle
- Cleaning up the battle and attack systems
- Rewarding the player
Skill Level Intermediate
1. Preparing the UI
2. Message Window
3. The Battle Window
4. Actor Classes
5. Battle Actions
6. Cleaning Up Combat
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.