Download

Help with a casting problem

The title probably sucks but I couldn’t figure out how to sum up what I’m trying to do in that small space.

I’m trying to figure out how to allow the player to select their character class, without setting one of the siblings as “default Pawn Class” in the project settings. So I want to be able to set the parent class (actually two parents up) as the default pawn class. Then when the player selects the child class they want to be, move them into that class. Additionally if they should select a different class at this point, it would move them into their siblings class. Now ordinarily if I had created that child class and I needed to cast down from the parent class it wouldn’t be a big deal. But since I haven’t technically spawned the child class, and I don’t know which class will be spawned, it is really confusing me. I’m probably looking at this problem the wrong way.

Bonus question

-Can the project Maps and Modes settings for Default Pawn Class be altered post game launch?

So i guess you mean the player presses a button to select a class? In that case i set an integer value. For the corresponding spawn logic i use this:

127c0ffa0fb563ed029e463671946a0fbe2506fc.jpeg

The pawn class is set in the GameMode, create your own gamemode set the initial pawn class. To change the pawn class you would create an extra GameMode with a different pawn class assigned (ie. for the menu). Then load that GameMode initially, before real game starts. On start load the other GameMode (ie. ActiveGameMode, and MenuGameMode) Though, i only use one pawn class which is hidden or not in the menu view, through widget backgrounds or hidden node settings. Still not sure if i need a second pawn class, because i basically want the player visible in the menu at one point (rotating character model view).

Edit

Oh i see you posted this in the C++ forum, still about to wake up here, sipping my coffee :slight_smile: