Posted November 22, 2024 by PixelPioneers2411
Respawn Functionality
Author: Ashtyn Roman
Posted: 11/21/24
This week one of the tasks I worked on was creating the logic for the player to respawn after being kills, so long as the base had not been destroyed. The first way I attempted this was to destroy the player upon death and then spawn in a new player. This caused issues with connecting the player to the game state and player controller. It also would remove the players inventory, causing them to lose any materials, defenses, or traps they had. This would cause frustration as the player would but put at a huge disadvantage on respawn.
The next method I used, was to simply disable the player temporarily, and make him reappear at the respawn point. This would solve the inventory issue, but also came with its own challenges. First, the player controller was causing the game to crash when I tried to disable it. I found the issue was that there was another player controller initialized in the file that was different than the original controller. Once I deleted the second controller, I was able to disable and then enable the player controller without any issues. I then had to reset some death values in other files in order to enable the player to have full functionality.