Fix stuttering in sliding part

You can see in the video that the frisbee stutters while it’s gliding. The frisbee is sliding on an invisible frictionless part. I don’t know what to do.

1 Like

What are you using to make that work? RunService?

1 Like

If you are using plain roblox physics modifiers like bodyvelocity, this is caused by lag in the workspace’s heartbeat.

1 Like

So maybe instead just try simulating the movement/collisions in a script

1 Like

I am not advanced enough to know what that means. I put the code in the the post

1 Like

Please only show the code responsible for making the frisbee move bc otherwise it will be harder to find the problem

1 Like

It’s in the “shot” function under the comment that says “set velocity”

2 Likes

I don’t know what you mean by this

1 Like

basically move the thing/make it bounce in a script

1 Like

the bouncing will just set its angle to the opposite relative to the side it touched, you can get that side via a raycast

1 Like

Looks like @miguelfriend9228 is right; stuttering is probably caused by lag from physics engine so u might have to simulate.

This setup might help as a starting point

local isFrisbeeBeingThrown = false
local velocity = Vector3.new()

local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = {frisbee, invisiblePart}
raycastParams.RespectCanCollide = true

local function progressThrow(deltaTime: number)
  frisbee.Position += velocity * deltaTime

  local raycastResult = workspace:Raycast(frisbee.Position, velocity.Unit * frisbee.Size.Z * 0.55, raycastParams)

  if raycastResult == nil then return end

  — this is where you handle collisions (you might want to do it differently)
  velocity = raycastResult.Normal * velocity.Magnitude
end

RunService.RenderStepped:Connect(progressThrow)

Somewhere in the throw function you would set the velocity and isFrisbeeBeingThrown variables as appropriate.

This lag is caused by NetworkOwnership issues, just set the frisbee’s NetworkOwner to the server.

Code (at the very top of your script):

local frisbee=script.Parent
frisbee:SetNetworkOwner(nil)
1 Like

Good idea; and although I’m not the OP, wld u pls explain why it’d be better in this case to set network owner to server versus client?

If you set the NetworkOwner to the client, you’ll have to set it to each new player that goes near the frisbee, and you’re risking security because now that client can delete the part (and it will replicate to the server). Way easier to do one line than setting up a bug-prone system like what I mentioned.

1 Like

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