Over the last couple of days I’ve been cleaning the code up a bit. I had a bool in the player character called bPerformingTask which I was setting whenever the player was doing anything that needed to take the controls away from the pawn. I’ve instead opted for an enum in the player controller. I currently have four modes.
- PlayerCharacter (Enable Character Input, Hide Mouse)
- Task_Possess (Disable Character Input, Enable Task Input, Hide Mouse)
- Task_Mouse (Disable Character Input, Enable Task Input, Show Mouse)
- Vote (Disable Character Input, Disable Task Input, Show Mouse)
I did this because some states require the mouse cursor, and others need to appear like the controller is possessing the task, so it’s useful being able to set all of the requirements in one place in the controller.
I moved most of the input bindings to the Player Controller from the Player Character. This is mainly so it can talk to both the player and the task depending on the situation.
I also added the player death to the player who gets voted out. I reused the code for when the killer murders a player, but like I said in the previous post I’ll probably add a proper visual for when the player is evacuated from the base.