#Sliding working mid air

1 messages · Page 1 of 1 (latest)

delicate jacinth
#

please help

#
local char = script.Parent
local humanoid = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
local slideAnim = Instance.new("Animation")
slideAnim.AnimationId = tostring(script:WaitForChild("SlideAnim").AnimationId)
local KEYBIND = Enum.KeyCode.LeftShift
local COOLDOWN = 2.4
local SLIDE_DURATION = 1.2
local START_SPEED = 50
local MAX_SPEED = 60
local ACCELERATION = 8
local MAX_FORCE = 20000
local canSlide = true
UIS.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if input.KeyCode ~= KEYBIND then return end
    if not canSlide then return end
    if humanoid.MoveDirection.Magnitude <= 0.1 then return end
    canSlide = false
    -- Disabilita la rotazione automatica del corpo durante lo slide
    humanoid.AutoRotate = false
    local animTrack = humanoid:LoadAnimation(slideAnim)
    animTrack:Play()
    animTrack:AdjustSpeed(0.6)
    if script:FindFirstChild("Slide") then
        script.Slide:Play()
    end
    humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
    local dir = humanoid.MoveDirection
    if dir.Magnitude > 0 then
        dir = Vector3.new(dir.X, 0, dir.Z).Unit
    else
        dir = hrp.CFrame.LookVector
        dir = Vector3.new(dir.X, 0, dir.Z).Unit
    end
    local attachment = Instance.new("Attachment")
    attachment.Parent = hrp
    local velocity = Instance.new("LinearVelocity")
    velocity.Attachment0 = attachment
    velocity.RelativeTo = Enum.ActuatorRelativeTo.World
    velocity.MaxForce = MAX_FORCE
    velocity.VectorVelocity = dir * START_SPEED
    velocity.Parent = hrp
    local speed = START_SPEED
    local startTime = time()
    while time() - startTime < SLIDE_DURATION do
        speed = math.min(speed + ACCELERATION * 0.1, MAX_SPEED)
        velocity.VectorVelocity = dir * speed
        task.wait(0.1)
    end
    velocity:Destroy()
    attachment:Destroy()
    animTrack:Stop()
    humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
    -- Riabilita la rotazione automatica del corpo dopo lo slide
    humanoid.AutoRotate = true
    task.wait(COOLDOWN)
    canSlide = true
end)```
jagged jasper
#

1 sec

honest summitBOT
#

studio** You are now Level 2! **studio

jagged jasper
#

@delicate jacinth

#

i fixed the problem

#

if you have fixed it yourself already just let me know

jagged jasper
#

local MAX_FORCE = 999999999

local velocity = Instance.new("LinearVelocity")
velocity.Attachment0 = attachment
velocity.RelativeTo = Enum.ActuatorRelativeTo.World
velocity.MaxForce = MAX_FORCE
velocity.VectorVelocity = dir * START_SPEED
velocity.Parent = hrp
velocity.ForceLimitMode = Enum.ForceLimitMode.PerAxis
velocity.MaxAxesForce = Vector3.new(999999, 0, 999999)

#

add these 2 lines in your velocity define logic

#

and change the maxforce number that you defined at the top

#

to what i changed it to

#

let me know if it works

#

just ping me

#

@delicate jacinth

delicate jacinth
#

now this happens

#

@jagged jasper

jagged jasper
#

are you still sliding mid air?

delicate jacinth
#

nope

jagged jasper
#

ok so if thats fixed what is the new problem

#

is it the character turning

#

when sliding

delicate jacinth
#

yh

jagged jasper
#

lemme look into it

#

as when i was testing your code in studio

#

i dont have the animation so i just removed that part of the code

#

so on my test it looked normal

delicate jacinth
#

and now a bug that i fixed showed up again

#

basically when i slide into something my character flings

jagged jasper
#

flings like out of the map or just like falls over and not standing?

#

with the animation it might be anim priority issue but im not sure

#

as when im testing with no animation

#

the character is not turning at all in anyway

#

or the way your camera module is making it work

jagged jasper
#

ive had this problem before

#

let me find the fix rq

#

humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.PlatformStanding, false)

delicate jacinth
#

priority is set to action

jagged jasper
#

you need to set the humanoid state while the dash is on

#

so fallingover etc is false

#

then when you slide into something it shouldnt happen

honest summitBOT
#

studio** You are now Level 3! **studio

delicate jacinth
#

where do i put ts

jagged jasper
#

for now just put it where you put jumping false in the code you sent

#

and tell me if it fixed it

delicate jacinth
#

like under or do i have to replace it

jagged jasper
#

under

delicate jacinth
#

it kind of fixed it

#

dont mind the voice

#

but yeah ig its fixed

jagged jasper
#

it might look odd because its a slide

#

i used this for a dash

#

and it was fine

#

but i was using body velo

delicate jacinth
#

its fine dw

#

but the thing is still there

#

the turning

jagged jasper
#

and the animation turning is either your camera module or anim priority as when i test with no animation the character is not turning at all

delicate jacinth
jagged jasper
#

does your camera module have unique shift lock or anything like that

delicate jacinth
#

i didnt work on that my friend did sadly

#

i got 3 camera scripts

#

Camera, Camerabobbing and cameragyro

jagged jasper
#

also autorotate stops the character from looking where the camera is but any external force will move it

#

like sliding on the floor

#

could be moving your character slightly

#

which could be causing the turning

delicate jacinth
#

so i remove autorotate?

jagged jasper
#

do you want the character to turn at all in the slide?

delicate jacinth
#

my friend didnt want to but i can tell him it was to fix a bug

#

yh it was that

#

ty

jagged jasper
#

np