Hello Devforum!
I am currently trying to make a movement based Playercontroller using the Controllermanager feature in roblox.
And everything has been working great!
I even was able to make the thing working that I was mainly trying to be able to use with it, maintaining momentum after jumping!
Problem now is, that i’ve not found a way on how to let this still work even when I’m pressing movement keys.
Because when i press soemthing, it just overrides it, and I dont like that.
Instead I want to make it work that I can still move a little in the air, but not fully, while maintaining my momentum:
What I’ve tried is basically doing some weird stuff like multiplying the MoveSpeedFactor with the velocity of the body but it didnt work.
(also if you want to see some of the code, i just followed this tutorial https://devforum.roblox.com/t/how-to-actually-use-robloxs-physics-character-controllers/ , mainly didnt add anything special that could affect this behaviour)
If any additional information is needed, please tell me!
So I’ve found a way to do this lol
i just firstly disable the MaintainLinearVelocity and set the MoveForce thing from the aircontroller to 0
and i just did it with this code
local player = game.Players.LocalPlayer
local character = player.Character
local controllerManager : ControllerManager = character:WaitForChild("ControllerManager")
local function stepController(t, dt)
if controllerManager.ActiveController == controllerManager.AirController then
local inAirInfluence : number = 0.035
local humanoidRootPart : BasePart = controllerManager.RootPart
local moveDirection : Vector3 = character.Humanoid.MoveDirection
local currentVelocity : Vector3 = humanoidRootPart.AssemblyLinearVelocity
local horizontalVelocity = Vector3.new(currentVelocity.X, 0, currentVelocity.Z)
local speed = horizontalVelocity.Magnitude
if moveDirection.Magnitude > 0 then -- is moving
local newDirection = horizontalVelocity.Unit:Lerp(moveDirection.Unit, inAirInfluence)
local newVelocity = Vector3.new(
newDirection.X * speed,
currentVelocity.Y,
newDirection.Z * speed
)
humanoidRootPart.AssemblyLinearVelocity = newVelocity
end
end
end
game:GetService("RunService").PreAnimation:Connect(stepController)