Character Aim and Shoot on Mouse Cursor in 2D Platformer

Hi Everyone!

I’m trying to create a 2D platformer shooter game. My goal is to create a mechanic where a character will aim and shoot towards the mouse cursor (basically 360*). I went through all possible references for the past 10 years but somehow I’m still stuck.

Some context: I’m currently using a “Muzzle” component to rotate the direction of shooting. Later on it will be a character arm with a weapon. I have a feeling that my cursor is moving in 3D space instead of 2D, but even though I manage to rotate only 180*.

Please help, I’m really desperate :frowning:

Here is my blueprint for shooting mechanic:

Here is my blueprint for aiming mechanic:

Animation

assuming the mouse is projecting down onto a plane i think you want to use the Z not Y

I figured it out, don’t ask how :smiley: It did not work because my background had no collider.

Adding a transparent pane with collider behind the scene fixed the issue and it works fine now.

Tried to show the result, but:
“An error occurred: Sorry, new users can only put one embedded media item in a post.”

Here is the solution:

And this is the result:

Animation

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.