What is my goal?
So I’m making a movement system and I have made a “wishdir” variable that outputs a vector3 depending on the players inputs. (i.e. if the player presses W, wishdir becomes 0, 0, -1 S it becomes 0, 0, 1 etc.) I’m working on making this vector3 relative to the player’s camera so movement is sensical.
The Issue:
My issue is that when the player moves their camera’s pitch, the wishdir moves with the camera. In the video provided you can visually see the wishdir as a blue line, and it’s relativity does work with horizontal camera changes. but I’d like to be able to nullify vertical changes without simply multiplying the Y of that vector by zero as I still want to be able to act on jump inputs (0, 1, 0)
What have I tried?
I’ve looked over the Devforum and haven’t found any solutions that don’t just multiply that Y value by 0.
If that is required, is there another way I can still include the jump input somehow?
My Code:
These are the important two lines that I think I have to add some math to somewhere but I’m not exactly sure where or how.
local camera = game.Workspace.CurrentCamera.CFrame -- grabs the Cframe of the player camera
local newdir = camera:VectorToWorldSpace(wishdir) -- orients wishdir using camera and gives it to newdir
Any help would be greatly appreciated, thanks!