itch.io is community of indie game creators and players

Launching enemies with attacks

Jesus Silva - 2/1/23


The Problem

This week, I was working on the shield utility for our game, moving past weapons, now I was tasked with making some progress on other equipment that served more of a supporting role to our existing weapons. The shield is mostly a defensive utility piece of equipment that can reduce the damage the player takes when it's up. The primary ability it will have is a big shove that does little damage but in turn,  gives the player room to breathe for a second or two. The main issue with making this shoving attack is that I of course had to make it launch the enemies it hits a short distance away from the player. When I was first trying to find a way to launch the enemies, I tried just changing their location and dropping them from a certain height, but that became incredibly math-intensive very quickly and became too much to be done very quickly for a spur-of-the-moment attack.  So with this issue of wanting to figure out how to effectively launch characters without making it expensive for the computer or spending too much time on the issue, I turned to the Unreal Engine 5 documentation to see if there was anything already built into the engine that could help. 


The solution

As it turned out, the engine already did have some functionality to make it possible to launch any kind of character in the game with a specified amount of force. This method that I used called LaunchCharacter gives you the ability to launch characters in a specified direction, and it also lets you choose the strength of that launch and if the enemy's momentum can influence that launch force. This ended up working out well not only for the shield but for some previously made weapon attacks as well. Adding the ability to make any attack launch into my melee collision system for this game allowed me to specify if certain attacks would launch for other attacks, and if so, how far they would launch the enemy.

Leave a comment