Grab, throw, or pounce

So maybe this is a lazy or possibly even simple question,but how would someone go about setting up an enemy AI so that it can throw a player across the room, grab and lift them up in the air, or even pounce on them and attack(almost like a zombie, mutant or monster)?

1 Like

for most of the situations its a simple matter of doing some checks such as seeing if the enemy is in range of the player and the proper action has been called (throw, lift, attack).

from there you play a animation. for the throw and lift you would play a grab animation and at a specific point in the animation attach the player to the ai’s hands (socket), oh and disable the players input here if needed. for the pounce you play a hop attack anim.

the last step would be to execute the script for the specific action. for the throw you detach the player from the ai actor and apply a force which sends them flying (look into physics interactions / launch character for this). for the lift your already done unless you want to add in a way to put down the player or have them break free. for the pounce you would just need to add in a attack script and apply damage which will vary depending on your implementation (melee, fps, can attack miss, etc).

below is a little example which should get you started on the type of things needed. I omitted the animations and the anim notifies that you would use but this is the overall idea of the logic needed.

for the example i went with a grab and throw, and separated the task into 3 steps, Move to player, Grab Player, and Throw Player.

For movement (chase) i simply used a ai move to and if successful then we grab, if not we chase again.

For the grab we first do a check to see are we out of range (100uu) of the player, if true we go back to chasing, if false we attach to actor (player to this enemy), we disable the player movement, delay, then call the throw event. The pickup animation would would occur before the attach to and you could use a anim notify to run the rest of this script. The delay would be where your enemy walks the player to a ledge or something.

For the throw event we first reverse what we did in the last event by detaching the actor and enabling player movement. Then we launch the character. The velocity of the launch in this case is decided by the direction the enemy is facing, then we modify that value (vector + Vector) to give more upward direction, and finally we scale the vector as needed (throw force). The last thing i did was to delay so the enemy can admire his throwing skill and decide what to do next… chase so he can throw again of course.

2 Likes