You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
I want to acheive blade ball like physics, but using a bezier curve function and using fastcast module, -
What is the issue? so far, the ball’s motion isnt smooth enough, it appears not good enough
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i looked for solutions pretty much everywhere, i even used set network owner ship to be able to use renderstepped
Im here asking for a method to solve this problem or for a different method, as to what i should be using.
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local Points = workspace.Points
local startPoint = Points.StartPoint
local midPoint = Points.MidPoint
local endPoint = Points.EndPoint
-- In studs
local endDistance = 50
local midDistance = 25
local midHeight = 20
function quadBezier(t, p0, p1, p2)
return (1 - t)^2 * p0 + 2 * (1 - t) * t * p1 + t^2 * p2
end
local playerDebounces = {}
local currentMotionConnection = nil
local currentPlayer = nil
local function startMotion(hrpPosition)
local lookVector = hrpPosition.CFrame.LookVector
local startPosition = hrpPosition.Position + (lookVector * 5)
local midPosition = hrpPosition.Position + (lookVector * midDistance) + Vector3.new(0, midHeight, 0)
local endPosition = hrpPosition.Position + (lookVector * endDistance) + Vector3.new(0, -script.Parent.Size.Y , 0)
-- Set the initial position clearly
script.Parent.Position = startPosition
startPoint.Position = startPosition
midPoint.Position = midPosition
endPoint.Position = endPosition
local duration = 1 -- Duration of the motion in seconds
local elapsed = 0
-- Cleanup previous motion if any
if currentMotionConnection then
currentMotionConnection:Disconnect()
currentMotionConnection = nil
end
-- Smoothly update the part's position on the client
currentMotionConnection = RunService.RenderStepped:Connect(function(deltaTime)
elapsed = elapsed + deltaTime
if elapsed <= duration then
local t = elapsed / duration
local point = quadBezier(t, startPoint.Position, midPoint.Position, endPoint.Position)
script.Parent.Position = point
else
-- Ensure final position is set
script.Parent.Position = endPoint.Position
currentMotionConnection:Disconnect()
currentMotionConnection = nil
playerDebounces[currentPlayer.UserId] = false
end
end)
end
script.Parent.Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChild('Humanoid') then
local char = hit.Parent
local player = Players:GetPlayerFromCharacter(char)
script.Parent.motion:FireServer(player.Name)
if player then
local hrp = char:FindFirstChild('HumanoidRootPart')
if hrp and hrp:IsA('BasePart') then
-- Reset debounce for all players
for userId, debounced in pairs(playerDebounces) do
if debounced then
playerDebounces[userId] = false
end
end
-- Start motion for the new player if not already debounced
if not playerDebounces[player.UserId] then
currentPlayer = player
startMotion(hrp)
playerDebounces[player.UserId] = true
end
end
end
end
end)
local Players = game:GetService("Players")
local motionEvent = script.Parent.motion
motionEvent.OnServerEvent:Connect(function(plrName)
plrName = tostring(plrName)
local plr = Players:FindFirstChild(plrName)
script.Parent:SetNetworkOwner(plr)
end)
External Media
Please do ask me for more description if needed, im more than willing to provide the answers as long as i can reach my goal of completing this
There is a client script under a basepart named “Ball” and also a script under it and there is a remtoe event under it as well.
Do i use an unreliable remtoe event to update the ball’s render stepped from one client and update it on the server for everyone to see ?