The setup

Published April 22, 2024
Advertisement

This week I am beginning my role analysis and next week I plan to complete it! For this project, I am going to be using Godot for the first time as I heard that it allows for a fairly simple implementation of net code. I will note, more time than expected was spent this week downloading Godot as the website’s download was for some reason not working. I attempted to troubleshoot this before ultimately learning that it was also available on steam, and that download worked.

Onto the project, I began by using this tutorial which allowed me to get a solid basis for the netcode I was going to end up with, but in a localhost setting. https://youtu.be/K62jDMLPToA?si=yMatgS-TiRxxdCC0

After completing the tutorial, I was able to open the game in two different instances, but when I hit join on one of them, all I could see was the host’s player moving around and for some reason it did not spawn the second player’s player.

After some debugging, I learned that it was working the whole time, but for some reason when you hit join on the second instance it was spawning the character off screen. Then, when I attempted to move it would walk off the edge of the map, and I would never see it. Adding some invisible walls to the invisible platform fixed the issue. Here is a quick show of it working:

I then learned how to make the platforms and walls visible in Godot, which was a strange process of adding a polygon2D node to the platform object I made, and then adjusting the data points to create the sprite. Very strange, but it worked out:

I needed to move the buttons around in the hierarchy to make them still visible. To end this week, I wanted to see if I could make cameras work per player instead of one static one for the whole scene. I followed this basic tutorial and just added a camera to the player scene and then decided to just try it out. https://www.youtube.com/watch?v=PRxIa9c0Zb8

And it seemed to be working! It was kind of weird that the buttons were anchored in the scene and not on the camera though. I added some export references (which so far I understand them as being similar to serialized fields in unity) and a couple lines on either button press to make them invisible (I just guessed on typing .visible and it worked) and:

It seems like they no longer show after hitting one! I had yet to test if the camera worked with both debug windows though, and when I tested it:

It didn’t quite work. In this gif, the host is on the left window and the joined player is on the right, and it only seemed to follow the hosted player. So, getting each player a personal camera was not quite as simple as just adding a camera to the player object.

However, my hot streak (of 2, after this attempt) of just trying things in Godot continues, as I made an export variable to contain the camera on the player script and then just called “camera.make_current” within the logic checking which player you are controlling and it seems to have worked!

So, this week I was able to get into a new engine, get some basic local multiplayer working, and add a touch of polish! I will continue this project by adding some sort of game to play with a friend soon!

See part 2 here

Next Entry The Game
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

The Game

9844 views

The setup

9558 views

Groundwork

12284 views
Advertisement