Today I have learned a very important lesson. This lesson is that in life, spelling, is of the utmost importance. Think about it, if you can't spell your own name, how will people know who you are? If we spelled cities differently each time, how would we navigate to Palo Alto or Aplo Aito? Well, even though computers are logical creatures, they definitely need you - the user, programmer, engineer - to know how to spell.
One of my issues, one of many of my issues, was caused by a simple misspelling. The stack trace told me where the error is. I thought I changed it, but when I uploaded it, I misspelled the directory, therefore leading me down the rabbit hole of "I swear I fixed that" and "I don't know why my code doesn't work."
I may have posted about this twice, but it is a stupid thing to do, misspell words. I really hope it does not befall you on your adventures in game programming.
Now for some real updates. I have finally fixed the code in the Client application to properly display names of users in a game that the player joins. This issues was brought on by how Unity loads levels and some shuffling of code.
If anybody has taken a look at the source code they would know that when a player joins a room, the game manager is prepped with a queue of players who are already in the room, or are joining the room. It supplies the script with both the player's name and the player's id on the network. If the queue is filled, it will copy this data to a new dictionary and iterate over this to put the relevant data in an instantiated object in the game and put it in the player dictionary.
This method worked fine, until player names were not showing up and they had to be added in the update method when the client received a foreign transform message. The instantiation turned out to be happening before a level fully loaded and so was creating players in the previous scene in Unity, and destroying them. This meant they existed, but then didn't exist at the proper moment.
I fixed this by only allowing the queue to be emptied in the multi player or single player scenes. Now the player names and ids are displayed properly and data is passed back and forth without incident. I also set the labels for names to clamp to the view port. This will prevent players from seeing a name of a player who is actually in the opposite direction. It will also now act as sort of a radar on the HUD. I like it, but I need to see if other players enjoy it as well.
Next I will be fixing one last server issue in which multiple death notices go out when a player dies, leading to a whole flood of errors.
Until next time, enjoy game programming and check out the revised version on my google drive.
No comments:
Post a Comment