#how can i get a velocity in a direction like this?

1 messages · Page 1 of 1 (latest)

left fractal
#

so i want to make a wall jump that goes in a diagonal direction like the picture sent, but i dont know what kind of math i gotta do to get a vector like it.
i already made a system to detect which side of the wall your on i just need help figuring this out.

indigo acorn
#

there are a lot of ways in which a wall jump can be implemented, you gotta be more specific in how you want it to work. is this based on any existing games?

left fractal
#

no

#

i just cant figure out the math to get a velocity in that type of direction

indigo acorn
#

is it always in the same relative direction?

left fractal
#

uhh

#

itll change depending on what side of the wall ur on

#

if the wall is to the left of u you'll get launched away to the right

#

i can show the current code i have if u want

#

it currently goes upward and sideways away from the wall

#

but it doesnt have the extra forward velocity in the screenshot

#

actually lemme just get the full thing

#

hold on i forgot how to format as code

#
    local rightwall = workspace:Raycast(
        HRP.Position,
        HRP.CFrame.RightVector * walljumpdist,
        wallparams
    )

    local leftwall = workspace:Raycast(
        HRP.Position,
        -HRP.CFrame.RightVector * walljumpdist,
        wallparams
    )

    local wallhit = rightwall or leftwall
    local wallside = if rightwall then "RightWall" else "LeftWall"

    if wallhit and wallhit.Instance:HasTag("Wall_") then
        touchingwall = true
        wallGUI.Text = wallside
    else
        touchingwall = false
        wallGUI.Text = "no wall"
    end

    UIS.JumpRequest:Connect(function(input) --walljump
        if WJdebounce then return end
        WJdebounce = true
        task.delay(0.1, function()
            WJdebounce = false
        end)

        if candj == true then
            if humanoid:GetState() == Enum.HumanoidStateType.Freefall then
                if sliding == false then

                    if touchingwall == true then
                        print(wallhit.Position)
                        local wjbv = Instance.new("BodyVelocity")
                        local raystart = HRP.CFrame.Position
                        local raydirection = wallhit.Position
                        local rayresult = workspace:Raycast(raystart, raydirection, wallparams)
                        wjbv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)

                        print(rayresult.Normal)
                        print("WJ attempted")
                        wjbv.Velocity = (rayresult.Normal * humanoid.WalkSpeed) + (HRP.CFrame.UpVector * 50)
                        wjbv.Parent = HRP
                        task.wait(0.1)
                        wjbv:Destroy()
                        candj = false
                    end
                end
            end
        end
    end)
end)```
#

there]

#

now its code

#

and here is a recording

#

of how it currently looks

hoary valve
#

have you fixed it?

proper pastureBOT
#

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

left fractal
#

I figured it out