The creation of a NPC or enemy character is similar in setup to the creation of a player character at first.
The main difference is that the movement is controlled by blueprints, which allow the NPC to perform program controlled tasks.
Our NPC is an enemy, so we want it to find the player!
This piece of blueprint code allows just that, finding the player position and telling the NPC to move towards that position.
I noticed that when the NPC was moving towards the player, it's animation was glitching. This appeared to be caused by the enemy's speed being reset every time it received a new move to command.
In my version of this code there is a temporary variable which stores the speed before the move command, and feeds it back into the character afterwards, allowing it to keep the same speed constantly and avoiding the animation glitch.
No comments:
Post a Comment