I want to make a dash the moves in the direction the character is moving not in the direction the character is looking

The Dash in this line of code works whenever I press shift, However the problem is that it dashes in the location that the character is looking, kind of like gengi’s dash. What I want to happen is have the player dash in the direction that the character is moving at the time of the key press regardless of camera orientation. Please Help!

Instead of using the Camera forward vector, use the Actors forward vector or forward vector of the character.

That would move the actor along the forward vector rather than in the direction they’re currently moving.
As in, you’re strafing to the left but looking ahead, dash should move you where you’re strafing, not where you’re looking.

I think that’s what @SSC_RED_DRAGON wants, no? Sounds a bit unclear to me.

In case what Dune suggested does not work for you, consider the following:

1 Like

Thanl you that worked perfectly. Sorry if there was any confusion on what I was asking.

That’s great, consider flagging this answer as accepted if it’s working as expected.

Take what Everynone suggested. The resulting normalized vector (before the 20000 scale) provided gives you the direction of the dash. You can scale this by however far you want your dash to be in order to get a vector representing the offset which can be added to an AddWorldOffset or can be used in calculating a new transform/ world location for SetActorWorldTransform.

One Caveat. This assumes that your player character is actually a Character with a CharacterMovementComponent and not just a pawn, since GetVelocity is only valid for simulating physics bodies or for actors with defined movement components.

There is something called GetLastInputMovementVector in the Pawn, I think it can be used for this, too.

I mean, you can always store your position from .1s ago, and get directional vector by comparing it to your current position.