I am trying to find a good way to switch between characters without all these Errors. I have a parent class “PlayableCharacter” with the Component “AC_PCStats” that holds the characters variables like life, energy and ammo. and 2 child classes. One “ThirdPersonSimpleCharacter” the other “FirstPersonSimpleCharacter”. I have tried to do this a few different ways and this is where I am currently stuck at.
In the Begin Play Event i first check if it it creating a new character or switching from one using the variable “IfNewPlayableActorSpawn” inside the game instance. If not then it creates The UI and adds it to view port.
On the UI Event Construct it calls the Function “SetMyCharacter” that sets up the Variable “MyCharacter”
MyCharacter is used in this case to get the Health of the character as its bound to a Progress bar.
Switch Character is currently in each child blueprint at the end of the blueprint I am trying to call the SetMyCharacter again in the UI. This Event seems to be where the problem is. When the Character switches, the Variables in “AC_PCStats” or the UI do not switch to the new Character.
Now when I switch the characters I get Access errors from trying to read the variables that are not there.
I am trying to transfer the Variables in the Component “AC_PCStats” between the switched characters, and get the UI to read the current characters stats. So when the Actors switch your health on the UI stays the same.
In game I want to press a button and switch between characters or vehicles in a list who might share the same UI and or Stats. I will also be using this during map transitions and the Save/Load process
In game example - Your Character walks in front of a bus. Now they are a ghost. You wonder around till you posses a Gorilla from the zoo. Now you have to escape so you steel a truck and drive off into the sunset.
The Character, Bus, Ghost, Gorilla, and Truck are all separate Actors that you can poses. When Switching from Character to Ghost then to a Gorilla the previous Actor is destroyed. When entering a vehicle the actor will be locked while in control of the vehicle.