Quantcast
Channel: Answers for "Attack selected Enemy Turn Based Combat"
Viewing all articles
Browse latest Browse all 4

Answer by DRRosen3

$
0
0
You don't have to have every ability in the enemy script. Put this in the enemy script. public void AdjustHealth(int amount) { health += amount; } Now you need some sort of mediator between player and enemies. I've done something similar in a project of mine called a "TurnBasedCombatStateMachine". A great tutorial series on this can be found here: [Make A RPG Series][1]. In it he teaches you how to make a turn-based combat state machine, a damage calculation script, and various other things. However, the two I mentioned are most important because you use the state machine to determine whose turn it is to attack and to calculate the damage. Once the damage is calculated, you'd call the function above. Something such as... if(player_damage != null) { enemy.AdjustHealth(-damage); } [1]: https://www.youtube.com/playlist?list=PL55tV-_J4r7SKl-vI7VfoX8RgG2aGVqzy

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>