How can I make this work for the players forward direction?

I have this function that uses a bezier curve for leaping, however, I’m not to sure how to make it move the player in the direction they’re currently looking in.

local function leap(character : Model, distance : number, height : number)
	local root = character:FindFirstChild("HumanoidRootPart")
	local distance = distance
	local height = height
	local pointA = root.CFrame
	local pointC = pointA*CFrame.new(0,0,distance)
	local pointB = pointA:lerp(pointC,0) * CFrame.new(0,height,0)

	for i = 0, 1, .1 do
		root.CFrame = CFrame.new(Util:QuadraticBezier(i,pointA.Position,pointB.Position,pointC.Position))
		task.wait(0.01)
	end	
end

Do you mean

  • “in the general direction their camera is facing on the Y axis”,
  • “in the direction their root part’s LookVector is pointing”, or
  • “in the current MoveDirection of their Humanoid”?

Just whatever the players facing which I think is the second option you said. This is what my code is currently doing.

Seems like you might be able to just change

-- make distance negative for "in front"
local pointC = pointA*CFrame.new(0,0,-distance)

and

-- keep the old rotation and just use position
root.CFrame = pointA.Rotation + Util:QuadraticBezier(i,pointA.Position,pointB.Position,pointC.Position)

see if that works

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.