I’m trying to make a simple networked game where each player has an avatar, can move around, and drive a car.
Currently, it works great when I run it “offline” (not connected to server). Now, I’m trying to make it work with several remote players, and I’ve hit a wall.
The plan is for the game to have a classic client/server architecture, with the clients sending information about attempted movement to the server, which executes the movement and sends back correct values for positioning et cetera. The server then has all the correct data, and the clients are fed this information.
I am using CharacterControl (yes, I know it’s deprecated but bear with me) and CarControl for moving the avatars/cars. While developing the networked side, I am currently not controlling the avatar locally at all, instead, I am sending orders to the server to adjust my walking/facing direction (which CharacterControl then uses).
Information about all avatars’ position and facing direction is continuously sent to clients, and while correcting the positioning of the avatars works fine, correcting the facing direction is not.
When a packet is received by a client, I am using CharacterControl’s warp (yes I know that continuous snap convergence is not optimal, but it’s just to start out with) to adjust to correct position, and simply changing CharacterControl’s setViewDirection to adjust the facing direction.
The results of this is that the movement is somewhat smooth, but the facing direction updates super rarely! These are just two separate lines of code that are executed right after eachother. Calling warp() instantly changes the position, but calling setViewDirection does not change facing direction until 1-5 seconds after.
After trying to make this work for a long time - I am stuck. I feel like using CharacterControl and CarControl works really well for how I want the game to look and feel, but it seems really hard to use them in a networked game.
If anyone has any tips on how to approach this problem or alternative solutions for a networked game of the type I’m describing, I would be very happy to hear from you!