Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would i move the player on a curve as if it was a long or high jump?

Asked by 4 years ago

to accomplish this, ive been experimenting with body movers, mainly vector force and body velocity.

    local vforce = Instance.new("VectorForce")
    local attach = Instance.new("Attachment")
    local character = player.Character
    local hrp = character.HumanoidRootPart
    local humanoid = character:WaitForChild("Humanoid")
    humanoid:ChangeState(Enum.HumanoidStateType.Physics)
    attach.Parent = hrp
    vforce.Attachment0 = attach
    vforce.ApplyAtCenterOfMass = true
    vforce.Parent = hrp
    local cf = hrp.CFrame
    local magnitude = 65
    local duration = 6
    local force = (hrp.CFrame.upVector + hrp.CFrame.rightVector) * magnitude
    vforce.Force = force
    local connection
    connection = stepped:Connect(function(step)
        magnitude = magnitude - step/duration
        vforce.Force = force * magnitude
        if magnitude <= 0 then
            connection:Disconnect()
            vforce:Destroy()
            attach:Destroy()
        end
    end)
    humanoid:ChangeState(Enum.HumanoidStateType.Running)

this was my vector force attempt it didn't work very well https://gyazo.com/0b84a122998d52f89f370c8280d3d84c

        local force = Instance.new("BodyVelocity")
        local character = player.Character
        local hrp = character.HumanoidRootPart
        force.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
        force.Velocity = (hrp.CFrame.upVector*42 + hrp.CFrame.LookVector*25)
        force.Parent = hrp
        local connection
        connection = heartbeat:Connect(function(dt)
            force.Velocity = force.Velocity - (hrp.CFrame.LookVector*7 + Vector3.new(0, 35, 0)) * dt
            print(dt)
        end)
        local counter = 0
        local interval = .1
        local connection2
        connection2 = heartbeat:Connect(function(step)
            counter = counter + step
            if counter >= interval then
                counter = counter - interval
                local part = Instance.new("Part")
                part.BrickColor = BrickColor.new("Bright red")
                part.Anchored = true
                part.CanCollide = false
                part.Size = Vector3.new(1,1,1)
                part.Parent = workspace
                part.Position = hrp.Position

            end
        end)
        wait(2)
        workspace.Baseplate.Touched:Connect(function()
            print("touch")
            force.MaxForce = Vector3.new(0,0,0)
            connection:Disconnect()
            connection2:Disconnect()
            force:Destroy()
        end)

i had a lot more success with body velocity, but two major concerns with this are that its pretty slow and i haven't found a way to adjust its speed and im wondering if i could ever get it to a point where the jump feels clean. https://gyazo.com/6931b46f7ce72bb79ff60b4ef3bc45c2 i am open to other ideas for this kind of thing, my goal is to create a nice smooth curve for my jump that i can easily modify the speed, height, and length of the jump with and ill be syncing an animation to it aswell. thanks for reading my question.

Answer this question