BSc3b Week 15- Added weapons, attack animations and damaging/killing enemies


For weapon models I have the sword, bow and arrow models (For if I have time to implement ranged combat for bow and arrow) from: Low Poly RPG Fantasy Weapons Lite | Fab

For the attack animations I’m using the Stable Sword Inward Slash from Mixamo.

This is what the animation montage looks like in engine with it retargeted to the correct model also included in this is a notify called attack which when the animation reaches that point will call an event.

This is the notify Attack event which just casts to the player character and calls a custom event called Attack. This is in the Quinn animation blueprint.

This is the Attack node which just calls to an Attacked function in the sword blueprint.

This is what handles the attack input which gets the current montage if it’s equal to the sword swinging animation then it prints out already attacking otherwise it plays the sword swing animation montage.

Finally for the player character this is what attaches the sword actor to the player. This does this at the beginning of play by spawning an actor of the sword blueprint class and spawning it at the socket transform of the hand_rSocket of the player characters mesh. Then attaching the sword to that component socket. Also sets sword ref equal to the sword just spawned.

This is the Attacked function in the Sword which gets all the actors of the enemy class then loops each of them checking if they are overlapping the Blade (capsule collision of the sword) and if it is calling take damage in the enemy.

This is the take damage function of the enemy which minuses 50 from their health then checks if their health is equal to 0 which if it is it destroys the actor otherwise print strings the health.

This is what it looks like in game given that the enemy doesn’t have anything it does when it can’t see the player easy to hit them before they see you but can easily hit them in both instances. It does have some problems like it could look like it should hit the enemy sometimes but if it’s not overlapping when the attack notif is reached in the animation montage then it doesn’t hit them.

,