How To - Add an offset at the cursor position rotation

Heya all !

I try to achieve something that I guess its pretty simple if you’ve taken your math class correctly, but currently I struggle a bit around this.

My setup is a 2.5D game, with auto attack made of projectiles that are shot in the direction of the mouse cursor position. Everything right now works fine, but I want to add an offset at the starting position of my projectile, to not start at the current actor location of my player character, but with a little offset from my actor location AND in the right direction (of my cursor mouse position).

So far, I have :

My cursor mouse position in screen
My Player Character Location
The rotation value from my Player Character to my Mouse Position

I guess that with these values we can easily calculate an offset of X in the desired direction, but I don’t know how.

I’ve tried to play with the Add Local Offset node but doesn’t work as intended

Here some screenshots of my BP

Hey @Ocir-Tello!

Are you rotating your actor while aiming/ is your projectile always going to be in front of your actor? Or is this a side view.

If it is a former, you can add an arrow component and use it as a spawn point for your projectile. Here’s a great non Epic tutorial that gives an example:

https://youtu.be/ROMWCMmNBHE?t=3139

A screenshot explaining how exactly you want this to execute would help pinpoint what exactly you are missing and what to add.

Any additional information you can provide will be a big help in solving your problem!

1 Like

Hi!
Is something like this good?
MouseDirection

In this example you don’t need the arc, only the start and end offset for the projectile’s start and end locations.

The mouse’s direction is the return value of the normalize node

If you need other aproximation, let us know! :sparkles:

3 Likes

Thanks to both of you mates !

LucidGem, your solution works like a CHARM <3 ! Its perfect, thanks a lot

Have a nice day :slight_smile:

1 Like

You’re welcome :smile:
Have a nive day you too!