Hello Dev Forum. I am trying to create an ice skating system where the player is always moving in the direction they are facing like ice or roller skating in real life. For some reason, they would only move in one direction. Can anyone help me out?
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(math.huge,0,math.huge)
bv.Parent = Model.UpperTorso
spawn(function()
while true do
bv.Velocity = Character.HumanoidRootPart.CFrame.LookVector * 30
wait()
end
end)
Maybe just maybe the lookvector of the camera is better to use in this context try it out
local camera = workspace.CurrentCamera --we would have to transition to a local script
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(math.huge,0,math.huge)
bv.Parent = Model.UpperTorso
spawn(function()
while true do
bv.Velocity = camera.CFrame.LookVector * 30
wait()
end
end)
local camera = workspace.CurrentCamera
local run = game:GetService("RunService")
local char = script.Parent
local root = char:WaitForChild("HumanoidRootPart")
run.RenderStepped:Connect(function ()
local x, y, z = camera.CFrame:ToOrientation()
local newCF = CFrame.new(root.Position)
root.CFrame = newCF * CFrame.Angles(0, y, 0)
end)