To sum this up, I am multiplying the input by 150 and adding that to the pawn’s current location to find the new location I want to move to. If I press W it will return the location with 150 units added in the x direction.
Recently I implemented the ability to rotate the camera around the pawn, but I need to adjust the location to account for this. For example, if I rotate the camera 180 degrees and then press W it should now return the location with 150 units subtracted in the x direction instead.
I’ve tried a couple different approaches, like using the rotate vector around axis node:
If the camera angle is between -135 degrees AND 135 degrees OR between -45 degrees AND -135 degrees the input needs to apply to the opposite direction, with an accompanying function for the y input.
This also required a swap to determine which direction the input should apply to:
Glad you found an adequate solution. I’m not sure if any of the concepts in this old post might help, but I did find a solution many years ago to adjusting movement based on camera direction (albeit for a ledge climb system). The function is shown in the last image of the first post: 3rd Person Ledge Climb Movement System (Shimmy) with Accurate Control Input
For the dot product comparison, if “Get Control Rotation” doesn’t work for your setup, you could also try “Get Player Camera Manager” and drag out and “Get Camera Rotation” instead (just make sure you have assigned a Player Controller blueprint in your Gamemode, and inside the Player Controller you have also assigned a Camera Manager blueprint).
The missing key to understanding this for me was the realization that adding the direction the camera is facing (aka the forward vector) with the current character location will get a location in front of the character. This is illustrated below:
Getting the forward vector from a component takes into account the whole rotation, including pitch and roll, where I just want the forward direction based on the yaw/z rotation of the camera. You can split the struct pins instead of breaking them (aka BreakTransform), and then making new ones, to clean this up a bit too.
From there you just add or subtract your forward and right directions to get your desired end location, multiply it by a step factor (for how far away you want the character to move) and then add it to your current character location!