Join Dan Violet Sagmiller for an in-depth discussion in this video Destroy, part of Build a Real-Time Strategy Game with Unity 5.
- Now that the units are attacking each other,…we need to destroy them when they have no health remaining.…To do this, I'm going to go into the Scripts folder…and then into the Battle folder.…In the Battle folder, I'll create a new script…called Destroy On No Health…and I'll edit this class.…Now to begin with, I'm going to need to know information.…I need to know the current health,…and I'll find that inside of the ShowUnitInfo class.…So I need to get a reference to it.…I'll start out by creating a reference.…
private…ShowUnitInfo…And I'll call it info.…Then when we start,…I'm going to get that ShowUnitInfo class.…So I'll say info = GetComponent…<ShowUnitInfo>…Finally, during the update, I'm going to check…to see if they have no health left.…If <Info.CurrentHealth…<= 0…then Destroy(this.gameObject)…So now I'll save this script,…return to Unity,…I'm going to find the Prefabs,…so then I select the Drone Units,…scroll down.…
I'll click Add Component,…and I'll find the Destroy On No Health class.…Once this is in here,…I should be able to just press Play…
AuthorDan Violet Sagmiller
- Adding player positions and start info
- Loading prebuilt levels
- Adding camera moves
- Adding a unit
- Supporting navigation
- Adding unit owners and player objects
- Importing and setting up a HUD map
- Adding unit info and credits
- Creating HUD actions
- Building a command base
- Adding artificial intelligence
- Adding battle actions
Skill Level Intermediate
1. Initial Setup
2. Adding a Unit
3. Navigation Mesh
4. Unit Owner
5. HUD Map
6. Unit Info & Credits
7. HUD Actions
8. Command Base
9. Base AI
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.