Hi monkeys,
I have done a simple client-server architecture where every 30 fps a Transfom object is sent over the network to update the position of a spatial on the other clients. This architecture will be changed soon because now i’m trying to implement an authiorative server where users’s input is sent to the server that elaborate data and send it to other clients to update the game state. Owever, i nedd to implement some kind of interpolation on the transform object.
I’ve seen the function of Transfomr object:
[java]public void interpolateTransforms(Transform t1,
Transform t2,
float delta)[/java]
And the question is:
If the server sends an update, suppose, every time the transfom is changed, in wich way the object will have to be interpolated by the function?
Thx a lot
Well if you know 30fps it is , you know how many ms you have between updates (approx)
Now you dela movement of clientside objects 1 tick and move them fluently to the last sended position.
A far simple but offten sufficient way is to just move the clientobject 10% per frame towards the real position. usually looks good enough.
To tell the truth, this type of updating will be soon changed to save bandwith. In facts the next commit will include a input handler where every input will be sent to the server and than processed and broadcasted to all players. In this kind of architecture there will be something like this:
Client client server
an input handler that handles user input ----> An input sender
> a message listener
Server server client
an input processor
> a processed data broadcaster
> a message listener
Client message listener processor:
[java]
public void transformMessageReceived(TransformMessage msg){
// Estract data from msg
iinterpolateTransforms(Transform t1,
Transform t2,
float delta)
// What t1 and t2????
}
[/java]
The problem is that if the update of the object transform happens only when the player moves, so i can do something like:
[java]
public void transformMessageReceived(TransformMessage msg){
// Estract data from msg
iinterpolateTransforms(Transform actualTransform,
Transform msgTransform,
float delta)
// What about delta? it needs to be always the same value?
}
[/java]
But i wander if this mechanism will work in the right way because if i interpolate in this way the position of a spatial, does this spatial reach the real position, or have I to call this method in an alternative way?
Thnx a lot