Hi all, I’ve been facing an issue with teleporting objects when moved in a stepped function. The object would move normally along with the moving player, then suddenly ‘jumps’ ahead of time, making it very unnatural.
I have tried substituting deltaTime in random places but that doesn’t help obviously.
Here is my code:
game:GetService("RunService").Stepped:Connect(function()
local v = origin.CFrame:VectorToObjectSpace(humanoid.MoveDirection)
ball.Velocity+= ball.Scale.Value*Vector3.new(math.round(v.X),0,math.round(v.Z))*speed.Value
ball.Velocity = Vector3.new(ball.Velocity.X*friction.Value,ball.Velocity.Y,ball.Velocity.Z*friction.Value)
end)
Setting network ownership to a specific client doesnt mean it won’t render on other clients, it just means that the owner had direct control of the object, and so its a smooth rendering. It still gets replicated to the server and then to other clients.
I have never said network ownership doesn’t render on other clients. As I mentioned here:
What I am trying to explain is that network ownership is risky because the client owns that part, unlike the first method I explained. Please read before commenting false assumptions
I did read and understand what you meant, I just was making sure the op realized this fact.
I should have hit the reply to the post in general instead of replying to your post in specific.
My bad.
@viobola
Just out of curiosity since this has not been marked as solved, where are you running the script that is controlling the ball?
Is that in a local script?
According to the documentation saying
"As Stepped fires every frame, it runs on a variable frequency. This means the rate will vary depending on the performance of the machine. "
I would assume this is on a client.
If that is correct, then setting network ownership to the player who’s client is running this script would not be “risky because the client owns that part,” as @hatespine has stated.
This seems like a good idea. However won’t the server render overlap the client render? I really need the smoothness but I don’t know how to do this like you said.
For example, if the server object is located in (0,0,0),
the client moves it to (5,0,0),
then the server moves the ball to (1,0,0).
The client would see (1,0,0) now, as it is resetted, right?
Client code will execute faster than the time it takes for the server to send packets to our client, so it will most likely be overridden by the client. However, if you try it and experience overlap issues for some reason, you could remove the server rendering
For example, if the server object is located in (0,0,0),
the client moves it to (5,0,0),
then the server moves the ball to (1,0,0).
The client would see (1,0,0) now, as it is reset, right?
What you just said here is true, however, since we are updating it really quickly, as I said before, there will be most likely no issue
There is no reason why you’d need to render it on the server, so if this issue you described is happening just don’t render it.
If it needs to be rendered on the server, then you could kind of make a reference part/model to the original one and destroy it in all clients except in the server.
That way only the server will see that reference part/model and you can use it for rendering in the server only (since it is destroyed in the clients it won’t be replicated)