top of page
Search

Dev Log#15: How I am using the Player Controller

I've had a backlog of information to put on this space for a while but I'll be breaking it all down one step at a time.


The main functionality of the player controller in my project is to visualise changes of information to the player's HUD examples of this includes updating the player's ammo during the match, updating the player's score and death tally.


The functions responsible for setting and showing HUD related information all have input parameters because the information needed for these functions are located in another class, for example the health variable is a replicated variable found on the character class.

This is what a function call of a player controller function typically looks like I use the ternary operator to determine if the player controller variable is null, if so then cast to a player controller. Then call the appropriate function inside an if check.


During the process of testing these functions I encountered some bugs. One being that when my character was respawned in their health bar wasn't being reset back to 100. I fixed this bug by making use of the player controllers native function OnPossess which can be overidden and inside this function I'm simply calling the same SetHUDHealth function as in the previous screenshot.


Another bug was related to the death message that displays telling the play who killed them. This message was supposed to be destroyed/ hidden as the player respawned in. This behaviour wasn't displayed and it wasn't updating correctly as it would only display the first killer's name if another player killed you for your second or more death it wouldn't show this information and the message would linger on the screen for an uncomfortable amount of time after the player respawned in. Now the information needed for death message was found on the player state class.


After doing some research into the player state because this bug had me really stumped I found someone in the unreal forums talking about the net update frequency rate of the player state and its slower than classes like the player controller. Net update frequency determines how many times a second a class is considered for replication.


I therefore tried increasing the net update frequency to 66.f and the minimum net update frequency to 33.f so the amount of times the player state class will get updated for replication will be anywhere between 66 and 33 times a second. This did solve the bug and I would consider it an important issue as the bug was quite disruptive to player immersion. Its important to monitor the use of net update frequency in your project as having unnecessary actors consume unnecessary network resources can hurt performance.



 
 
 

Comments


bottom of page