Need help with sword attack direction based on mouse movement (+video example)

Hello everyone,

I’m a noob in making games but I have managed to build the foundations of my project through tutorials and reading you here.

I’m creating a game where I can pick up a sword form the ground and I would like to control the direction of attack based on the direction of the mouse.
Surfing the web I have found a video that is more or less what I want, although that video just shows the result and not the process.

From what I see it’s a 3rd person action game. I was rather making a 1st person RPG (using a thrid person character blueprint to simulate a “True FPS”). Anyways, can I get some guidance on how to do something like that?

Summary: basically I want to controll the attack direction based on the mouse movement.

Thank you.

This isn’t something easy to do for beginners but we highly encourage you to learn more.
To achieve something like that, there are a couple of stages that you need to do.

Here’s some pointers/area that will help you with this. Do some findings on these and I’m sure you will get what you wanted.

  1. Use animation layered per bone functionality to separate lower and upper body animations.
  2. Implementation of aim-offset functionality so that the character will always follow the camera rotation/location.
  3. Play attack montage on the upper body and locomotion animation on the lower body.
  4. Check if the camera is at 180-degree rotation (looking back) and rotate the character afterwards. You can find this on the Youtube tutorial as well.

Again, this is a huge topic to cover, but with some dedication and effort to do some study on these listed pointers, I’m sure you will learn better.
Hope it helps.

Hello,

thanks for answering.

As for point 1., I believe I have already managed to do that, although it is hard to tell since I’m using a metahuman and the Hands and Feet are in the same skeletal mesh, so I don’t know if this is going to be a problem to implement the layered animations per bone. At least for locomotion it is not a problem, maybe for attacking… What do you think?

Also, I am trying to find more documentation on how to make my character’s arm follow the mouse when having a sword in it (since that would make the sword follow the mouse?). Or maybe I should make the sword follow the mouse and make the hand of the metahuman stick to the grip of the sword. What do you think and how would you implement this? Maybe getting the mouse pitch and yaw and making this the position of the tip of the sword, so I should rig the sword and add some bones?

I am not finding much documentation on this matter, so I don’t really know how to proceed.

Thanks in advance.

I never tried Metahuman myself as it is still not well optimized for games. Also, I see a lot of body parts that will need to be combined manually. We will need to do tons of extra work to optimize it. I would recommend using a montage slot only for the upper body so it will play attack montage animation only for upper body.

This is what we called aim-offset (as I’ve mentioned earlier). There are tons of tutorials you can find anywhere. Although most of it is for TPS games, the functionality is just the same. There’s nothing special about setting your upper body to rotate following the mouse.

This video is Part 7. You can follow the whole series on how to set it up. Extra info, this video is not created by me, but my search-finding tutorial on Google in 1 minute. This video series should help you get your character to face the camera (at least).

Again, this is a huge topic to cover. Hope it helps.