Alexander Sjögren

Video Game Programmer

Back

Lab Jumpers

Lab Jumpers screenshot

Project Info

2021

Godot

1

8 Weeks

GDScript

Everything


Lab Jumpers is an online multiplayer platformer where you race against your friends in a variety of different levels. First person to the goal wins. Pick up power-ups along the way to complete the level faster, but make sure to watch out for the spikes.


About

Lab Jumpers was made as part of my high school graduation project (gymnasiearbete). The purpose of the project was to explore how a peer to peer multiplayer game could be created in Godot. To do this I choose to make a simple 2D platformer where the players race through a level and the first player to reach the end wins. The complete game was made in the span of 8 weeks alongside other schoolwork. Everything from programming to graphics and level design was done by me.

Multiplayer Implementation

The game is made in Godot 3.4 and utilizes Godot's High Level Multiplayer API to achieve peer to peer networking. A peer to peer approach was chosen to avoid server costs. This means that the game can be played over the local network or over the internet if the host sets up port forwarding.

The game has a lobby system where the player can either host a lobby or choose to join an existing lobby. Once on the lobby screen the players name and chosen color will be synched with the rest of the players. There is a chat where join/leave messages are displayed and the players can also write messages visible to everyone in the lobby. The host has the power to kick anyone from the lobby and can also choose which of the four levels should be played. This level selection is displayed to the other players. Once everyone has joined, the host can start the game. Everyone will begin to load the level and once every player has successfully loaded the level the race will begin.

In the level a character is created for each player and its network master is set to the corresponding player. This means that the character can only be controlled by the corresponding players network requests. Almost all packets in the game are sent using TCP to ensure they arrive. The only exception to this is movement packets that are sent using UDP. The players send their updated position every frame, therefore UDP was chosen to minimize latency. Packet loss was also not deemed an issue due to the frequency of the packets.

The host saves the time at the start of the race. When a player reaches the goal they send a packet to the host stating that they have finished the level. The host then compares the time the packet arrived to the time the level was started. This time is then sent out to every player to be displayed on a leaderboard. Once everyone has finished the level or the time has ran out the players are awarded points based on their placement before returning to the lobby. More players can then join and another level can be played.

Potential Improvements

One problem with the current join system is that the host needs to set up port forwarding in order for players outside their local network to join the lobby. This could be solved using a centralized server that helps connect the clients but that was outside of the scope of this project. Another thing I would have liked to implement is a lobby discovery system. That way the player wouldn't have to enter the IP and port of the host to join. This could be done by scanning the local network for games or by using a centralized server to enable lobby discovery over the public internet.

As mentioned earlier the players send their position to all other players each frame which is very much not ideal. This means that the amount of packages sent is dependent on the clients framerate. Since the game is fairly light the framerate is usually in the hundreds (even on weaker hardware) which means that the amount of position updates sent is way to high. One of the games biggest bottlenecks right now is the sending and receiving of packages.

Another problem is that the host has no authority over the players position. This means that it is incredibly easy to cheat by modifying the game. A solution to this would be to implement server reconciliation and client side prediction (to make the game feel more responsive). I would also have liked to implement client side prediction for the competing players to make their movement smoother. This would also require fewer position updates to be sent.

What I Learned

I learned a lot about the basics of network programming during this project. I learned how to connect two computers together and the various challenges associated with this. I also researched various solutions so that the host wouldn't have to set up port forwarding and I learned a lot about it even if I ultimately didn't have enough time to implement a solution. I also learned about various network topologies and protocols and how information is sent over the internet.

This was also my first "real" project in Godot and it taught me a lot about the engine and it's various tools. I also improved my game development and programming skills in general. The game I made is in no way perfect and that is reflected by the non exhaustive list of potential improvements, but overall I am happy with the project and I feel that I learned a lot from it.