Hi, I’m working on a system that will allow you to tween a CFrame of a PVInstance using :PivotTo(), with custom functionality like adding curvature, and custom easing styles. It functions using a loop, that increments the CFrame repeatedly, it creates an illusion of smoothness. I’m sure everyone is familiar with this effect.
The problem is I primarily wanted to use it on characters, and “animate” it on the server, and when I do that, on the server it looks fine, but on the client it teleports behind itself, of course because the server is assigning it a position that it THINKS it’s at, but in reality the client is already ahead of that position.
If you don’t understand, here’s what I’m asking:
How can I increment the position of a character without it teleporting backwards on the client?
No, I can’t, like I said before I need to tween it in a custom way because I’m using custom curves, like bezier curves so I can curve the cframe around points.
My issue isn’t with the smoothness, it’s just the fact that due to latency the server thinks the client is somewhere where it’s not, usually behind it. So the server reassigns it to a new cframe, and that teleports the character behind itself.
If the player isn’t able to control their character during the movement, you can change the network ownership of the player to the server. That way, the player will be experiencing what the server sees as there isn’t a way the player can update their own character. However, I am unsure if you are able to remove network ownership of the player from the client, so you may need to instead sub out the player with a replica of themselves and just do the movement on them.
If, however, you want to be able to move during this, then I don’t see why you cannot run this code from the client - after all, code relevant to the movement or control of a client should be handled on the client.
It varies, sometimes you can control it a bit a sometimes not at all. I think for the subbing out part I’ll pass because I’m going to be using this module A LOT for very small things, it will be very tedious. Plus I’ve had experience with using fake characters before and it can get janky.
I think it’s a good idea to do it on the client, but wouldn’t there be a noticable delay to other players? Think, after the server tells the client to animate, that’s one ping, then the client responds while tweening the cframe, that’s another ping, and then to other characters it has to to travel all the way to them, that’s 3 pings, that could build up especially in a server with bad connection, right?
The delay to others would only be an issue if all players are doing the same movement in synchronous, and to deal with that you would have to implement a predictive algorithm.
Let’s start with the best case scenario - this would be if your movement happens in isolation, so only one client is being affected. From the other player’s perspective, there won’t be any jitter and it would only be as out of synch as the sum of their pings (which is just the normal discrepency).
However, the worst case scenario would be if multiple players are being affected by the movement concurrently. Lets simplify this scenario down into 4 players moving in a straight line.
Here, the red square is the client, and the black, green and yellow squares are all other clients. As they are moving along at the same speed, our client appears to be further ahead than the other clients, however in reality they are all parallel and perpendicular to one another (the server view, i.e. the unfilled squares is the “truth”)
This issue only arises when the movement is handled on the client, however it can be fixed - by knowing that other clients are moving at the same speed, you can produce an algorithm which can predict the position of the other clients and as such draw them in the correct positions. Now, this won’t affect the other clients (i.e. won’t replicate), but will make it appear as though they are all at the same place. Using the same logic, if you knew the speed of all clients, you could predict for any variable of velocity.
This predictive technology, however, has its flaws when you consider that clients may be able to move during this; this makes sense, as it is “predictive”, and you cannot always sensibly guess where the player may choose to move. The best way to handle with this would be to constantly check the predictive state of the other clients matches up with their real state, and if it doesn’t you may have to alter the prediction.
Okay. It’s definitely possible that I would tween and move multiple characters at the same time. But if I do all of the tweens on the respective client, I should be good?