Help Make Actor Follow Mouse Direction Around Player

Hi guys, I’m trying to make a system that makes a component in my BP_player to follow the mouse direction, but I’m having one problem with it.
The Mouse position and the Component are mirrored. (See pictures)
The photos shows the first Event I made (Everything in one single event (RotateBallPosToMouseDirection))
The other 2 photos show that I separeted in 2 functionalities (TrackMouseDirection and UpdateBallPosition)
Both of them are being called EventTick.
Anyone can help me identify the problem?




EDIT 1.: If I change the math this way (see photo), everything almost works. The only (and big) problem is that now the ball is below the player, not above him. But the ball is following the mouse direction as it should be (See photo)


image

Hey @Peupz1! Welcome to the forums!

If it is mirrored vertically and horizontally, you can multiply the vector by -1 to reverse the angles:

If it is only X or only Z, you can multiply that value by -1 to flip it and remake the vector! :slight_smile:

image
That’s what happens when I multiply the vector by -1. :frowning:

(The ball is now under the floor)

EDIT 2.: I removed the Clamp (Float) Node and did 2 multiplications on the SINd and COSd.

This made the ball be able to move around the player on a 360° arc and follow the mouse direction.
Now I’ll try to make the ball not clip inside the ground while the player has it.

(Don’t know exactly what solved the problem with the ball following the mouse direction.


Untitled video -

You appear to be setting the Z (Height) location of the ball based on the mouse cursor.

I don’t think that’s what you want.

I Solved!
I mean, I didn’t, Suthriel on the Cobra Code Discord solved it!

I felt a little obligated to close this post too with the answer since I hope this can also help someone in the future.


This is the code.


This is the components necessary for the code to work.
We added a “Spring Arm” to rotate around the player (Same thing as before, but now working).
I can’t thank him enough.
Suthriel, if you read this. THANK YOU!

1 Like

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