I made a pretty cool replication system. I use it for projectiles. In order to make everything appear incredibly smooth, the projectiles are simulated locally. However, I would still like to control things on the server with a lot of freedom. This left me with a dilemma. I solved the problem by creating server projectiles that replicated each of their properties to the clients, which then updated their client projectiles with each property. This included things like position and velocity, so that no matter what the server was king of the situation. This whole solution allowed me to avoid awkward situations like the server and the client disagreeing on when a projectile hit a target, and allowed me to leave virtually all logic on the server (where it should live). Anyways, hereās a video showing it in action. Try to note the times when the projectiles seem to āchopā as their position, velocity, and color are corrected by the server. Oh yeah, and buddy and garnold got involved while I was testing so yeah. I explain stuff in chat to them too, so if you care you can listen to what Iām saying. Videoās probably overly long.
[video width=425 height=344 type=youtube]KvNFC8EqrQ4
Iād like somewhere to test this out.
Yeah, I sent a friend request since itās private.
Reminds me of something I did in a murder game I was helping with. When the player throws the knife, for example, the server raycasts and does damage instantly. It then tells the clients to simulate a flying knife that flies towards the point on the part it hit.
Ended up looking very, very nice. If you ever do something like that make sure to add an arc.
Iāll friend anyone who posts here.
Yep sent a friend request, looks awesome
Do you instantly apply the effects on the client or wait for server input? (sorry, I TL;DRād :()
Iād like to take a peek aswell :3
Not a problem. Because itās not computationally expensive (the way Iām doing it), the projectile conforms every renderstepped.
In writing this, I realize that Iāve defeated the purpose of it. Wow. So, Iām gonna go fix this and see if I canāt make it better. Lol. Wow.
So I have fixed it. It actually like looks better now. It looks almost perfect, to be honest. Take a look at this video, recorded live on the server:
All logic is handled on the server. All of it. The client just does what the server says.
New stuff: when it is a playerās character, the server puts as much power as is possible in the clientās hands so that the characterās jump is as smooth as possible. The server, on the other hand, handles moving the minions. The power of this replication system to make smooth but legal projectiles is astounding. Video:
[video width=425 height=344 type=youtube]znKl6AT2JNg
Wow. That is really smooth, I understand that you worked hard on it. But could you tell a little bit about how it works behind the scenes. Like how do you handle the Client / Server tasks that smoothly
I can guesstimate what is, so here I go:
When the client does something particle-related, the client instantly starts displaying those particles in a predictive manner - that is, they predict where theyāre going to be for when the server sends updates about its position.
The server calculates where the projectile/particles really are and every so often tells the clients where they really are, and some other useful information. (such as heading direction, rotation, etc)
This way, the server is authoritative over the projectiles/particles while the client still sees them nicely and doesnāt get any input lag.
Sent a friend request; Iād like to try this
Finite basically hit it on the head.
My local system has some logic on it ā it has a local simulation of the physics on its end. Essentially, if the server updates were ridges, then the gaps between those ridges are āfilled inā by the local simulator.
I use objects I call āreplicatorsā inside of an object in ReplicatedStorage. A replicator is created for each projectile, and the clients detect when a replicator is added into this object. When that happens, it creates a special local projectile which copies all data from that replicator as often as it changes, including position and velocity.
A replicator is essentially a container for a bunch of *Value objects. The local projectile watches for changes on that while simultaneously performing its own calculations.
This is interesting and everything and can be used in many situations, (the best one I can think about is correcting player movement) but when it comes to projectiles, if the server and client have the same mathematical function that controls the position, wouldnāt they virtually be the same? That is, if they are giving the same parameters.
Sent friend request.
I sent a friend request! This looks very cool!
[quote] Finite basically hit it on the head.
My local system has some logic on it ā it has a local simulation of the physics on its end. Essentially, if the server updates were ridges, then the gaps between those ridges are āfilled inā by the local simulator.
I use objects I call āreplicatorsā inside of an object in ReplicatedStorage. A replicator is created for each projectile, and the clients detect when a replicator is added into this object. When that happens, it creates a special local projectile which copies all data from that replicator as often as it changes, including position and velocity.
A replicator is essentially a container for a bunch of *Value objects. The local projectile watches for changes on that while simultaneously performing its own calculations. [/quote]
So basically you use a modified version of how Halo Reach does it? Neat. I also use a similar networking strategy in my games to make sure that the client has no perceived input lag.
[quote] Reminds me of something I did in a murder game I was helping with. When the player throws the knife, for example, the server raycasts and does damage instantly. It then tells the clients to simulate a flying knife that flies towards the point on the part it hit.
Ended up looking very, very nice. If you ever do something like that make sure to add an arc. [/quote]
That is genius. What did you do if the knife hit somebody else on itās way towards its goal?
@OP is also a genius.