Friday, 10 March 2017

Player and Enemy death/re-spawning

For the game to function fully, it is very important to have the player and enemies die correctly.

To control my death animations, I am going to use the State Machine to detect when the characters have died, then play the death animation.


Here you can see in my enemy state machine, I have three death animations, which when the enemy dies, it chooses one to play at random, so that when a large number of enemies are together and they die, it looks visually interesting.


Here is the code that destroys the character. This is triggered when the character's health hits 0 or below. The timeline is used to sink the body into the ground, so that it doesn't just disappear when it is destroyed.

This setup is almost identical for all my characters, including the player.

The only difference being, the player is able to re-spawn. This is done via an event in the Game Mode event graph.


And a system of Blueprint Checkpoints which update the re-spawn location when they are passed.


This makes it extremely efficient to place as many checkpoint re-spawns as required, anywhere in the level.

No comments:

Post a Comment