If i want to make a sonic momentum system, where you stick to surfaces depending on speed, how would i do this?
Right now I am trying to figure something out, this is what I have so far:
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
local dir = Vector3.new(0, -3, 0)
local normal = Vector3.new(0,1,0)
local force = Instance.new("BodyForce",hrp)
game["Run Service"].RenderStepped:Connect(function()
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Whitelist
rayParams.FilterDescendantsInstances = {workspace.wallrun}
if hum:GetState() == Enum.HumanoidStateType.Running then
if hum.WalkSpeed >= 75 then
local checkForWallrun = workspace:Raycast(hrp.CFrame.Position,dir,rayParams)
if checkForWallrun then
print(`Ray intersected with: {checkForWallrun.Instance:GetFullName()}`)
print(`Intersection position: {checkForWallrun.Position}`)
print(`Distance between ray origin and result: {checkForWallrun.Distance}`)
print(`The normal vector of the intersected face: {checkForWallrun.Normal}`)
local partnormal = checkForWallrun.Normal
end
end
end
end)
If you paste this in any old game and set your walkspeed to 75 it will work, but I don’t know how to use the vectorforce and other topics have not been very helpful.