I got a custom character controller but ive been having diffuculties actually getting movement in. I have the inputs and physics all working but cant figure out how to actually get the character to move the way i want to:
-- Main movement (MovementVector --> input direction relative to the camera)
function MovementController.Move(MovementVector: Vector3, DeltaTime: number): ()
-- All client vars
local currentVelocity: Vector3 = Client.Velocity --> the velocity of the character
local groundNormal: Vector3 = Client.GroundNormal --> the normal of the surface or vector.zero if not grounded
local grounded: boolean = Client.Grounded --> is on a surface
local onSlope: boolean = Client.OnSlope --> is on a slope above the max slope angle
-- All player movement settings
local gravity: Vector3 = MovementSettings.Gravity
local maxSlope: number = MovementSettings.MaxSlope
local friction: number = MovementSettings.BaseFriction
-- Getting the correct speed
local moveSpeed = MovementSettings.WalkSpeed
moveSpeed += Client.Sprinting and 12 or 0
moveSpeed += Client.Crouching and -6 or 0
-- Extremely basic and non reliable movement (just an example)
currentVelocity += MovementVector * moveSpeed
Client.Velocity += currentVelocity * DeltaTime
end
-- Apply gravity
function MovementController.Gravity(DeltaTime: number): ()
if Client.Grounded then return end
Client.Velocity += MovementSettings.Gravity * DeltaTime
end
-- Make the character jump
function MovementController.Jump(MovementVector: Vector3): ()
if not Client.Grounded then return end
Client.Velocity += Vector3.yAxis * MovementSettings.JumpForce
end
what ive been trying to do is add acceleration, friction and make it so you slide down slopes that are above the max slope angle. I have tried so many different combos of different things and im kinda just out of brain power now