Moving to where the player is looking


I’ve a system where the player is looking towards the mouse cursor. I’m encountering 2 problems with this system.

  1. I’m trying to only use the W button in this system but the player isn’t moving to where it’s looking but instead going in a straight line from the position where it started.

  2. The rotation towards the mouse is really fast and I was wondering how I could slow it down.


The End Work Looked Like This:

Controller BP

Character BP

And don’t forget the gamemode :wink:

Hey @Doeglas,

In your character BP, try replacing your get forward and control rotation with a Get Actor Forward Vector node. That should consistently make your W key move you wherever your character is facing.

As for the rotation speed, you can tweak that in your actors Character Movement Component. In the details panel for the character movement component, look for Character Movement (Rotation Settings) and make sure “Use Controller Desired Rotation” is unchecked while “Orient Rotation to Movement” is checked. Then tweak the value of the Z (Yaw) rotation rate to your liking.

I hope this information helps, and good luck!


Awesome! Totally did the trick.

Last problem I’m encoutering implementing the suggestions is that whenever I move my mouse near my character he starts spinning. Any idea how to fix that?

I probably think with a branch checking if the position is near the character to do nothing? I don’t know really, let me know if you have any idea’s.

Hey @Doeglas,

When you say near the character, do you mean underneath the mesh? If that’s the case, yes. You can use a Distance Vector node in your controller BP. Get the actor location as one input and tie the other into the vector of your trace under cursor. All this does is find the difference between the two and give you the result as a float. Use
this value as one input for a greater than or equal node, with the other at a relatively small distance - toy with this until you get the smallest distance the spinning stops occurring.

Then just check that the value is true against a branch node and you should be set!

I hope this helps!

1 Like

Totally did the trick, thanks!