I’m trying to allow my player to move on the X/Z axis when not touching the ground. Some approaches I have taken included setting gravity to 0, but that only stops me from accelerating downwards, I still float upwards. I tried bodyvelocity/bodyposition, but they are deprecated so I’d rather not use them. I’m thinking of using mover constraints, but I don’t know if they necessarily have the ability to stop velocity on a certain axis.
For more clarification, I’ve left this image. I’m airborne here and I want no movement on the +/-Y axis unless a force acts upon me.
Maybe try to loop the Y axis to a position Position = Vector3.new( Position.X, 10, Position.Z ) when it detects that Humanoid.FloorMaterial = Enum.Material.Air, that could work with a Script or LocalScript inside StarterCharacterScripts. I don’t know if I explained myself correctly.
I could see how that would work, but I’m worried it would be performance dampening. Also worried that it might vibrate the player since they will still be falling but their position would keep looping back to Y=10 until they finally tough the floor. I’ll try it regardless, though.
Yeah, you’re right but I don’t see much other ways. I’ve tried lowering the mass of all character parts to 0 which had few chances to work and it didn’t. Keep trying other ways tho, you may find the solution.
you can place a linearvelocity constraint into the character
set the velocitycontraintmode to line
set the linedirection to (0,1,0)
set the linevelocity to 0
you should set attachment0 to an attachment in the character
i think this should prevent your character from going up or down, while allowing you to move along X and Z
but it probably also keeps forces from being applied to the character, so you’re stuck at that Y
I tried what you suggested, but I’m a little confused if it works or not. I wrote a function that creates a linearvelocity with your specifications inside the humanoid root part, and an attachment is created as well which serves at attachment0. I don’t notice any change in my Y velocity, did I miss something?
UIS.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == jetkeybind and hrp:FindFirstChild("LinearVelocity") == nil then
Instance.new("Attachment",hrp)
local ylockerAttachment = hrp.Attachment
Instance.new("LinearVelocity", hrp)
local ylocker = hrp.LinearVelocity
ylocker.Attachment0 = ylockerAttachment
ylocker.VelocityConstraintMode = "Line"
ylocker.LineDirection = Vector3.new(0,10,0)
ylocker.LineVelocity = 0
end
end)
EDIT : This works if you set the max force to a large number. I just did math.huge and it works perfectly fine now.