Capsule won't stay on floor

I’ve been making pretty good progress on my custom character controller. My character moves, but when I look up it starts flying up. vel.Velocity = camera.CFrame.LookVector *fspeed +,gravity,0) + camera.CFrame.RightVector * sspeed Gravity is -5, and this uses a BodyVelocity

Should be pretty simple, just remove the y component to prevent flying up and down movement. But it will need to be normalized after removing the y component in order to prevent the speed from reducing if the camera is looking more “Up” rather than “Front” because the y component increases when looking “Up” while the XZ component reduces (this y component will be removed).

local movementVectorDirection = camera.CFrame.LookVector*,0,1)--Remove y component, or up and down movement
movementVectorDirection =movementVectorDirection.Unit*fspeed--normalize to length 1 and multiply it by speed factor
--repeat for right direction
local rightDirection = camera.CFrame.RightVector*,0,1)--Remove y component
rightDirection  = rightDirection.Unit*sspeed 
vel.Velocity = movementVectorDirection + rightDirection --sum to the two together

Here is a reference to a custom movement script made by @ThanksRoBama which mimics the default humanoid control movement system in the direction it moves. (The actual physics movement is still performed by the humanoid)

1 Like

Not too sure what’s causing this problem with the limited snippet.

Try making a different post with more information and using ``` to format your code so others can copy it to test it out and debug the problems easier.

I already fixed it, flagged it as deleted. The problem was that I had the up, down, left, and right stuff in a big if and else. I broke it up into two. Thank you for helping.

1 Like