Hi guys, can you tell me if the one in the image below is the proper way to get a reference to the pawn spawned by default by the GameMode or if there is a more straightforward one (like a “GetPlayerByID” node or something) ?
This way should work. With this cast you canget all the variable of that character. When you spawn it, you can store the actor variable somewhere and get it for to cast it after.
Also some noob questions, I’m kind of confused by the whole hierarchy here, so I would like to know if there is some page with a graph that visually show all the structure.
If I got it right, the GameMode has a “GameState” object which contains a PlayerArray which are not actually players but is relevant data for each player, like the variable “Score”.
So how do I add more relevant variables like that to a PlayerState in that array? Let’s say a variable “HitPoints”.
Also, a PlayerState knows it’s owner, which is a PlayerController, and the PlayerController also owns a Pawn, so I am confused as to why isn’t the other way around, meaning why PlayerArray isn’t an array of PlayerController, or why it isn’t simply called PlayerData Array.
Also if I needed to move that Pawn, I would change it’s position, right?
Or as the name PlayerController suggest, am I supposed to control the Pawn troughs it? And if not, then what it is a PlayerController for?
Also, am I in charge of manually updating the data inside the PlayerArray of is that data automatically being tracked and retrieved for me?
You can also set Project-Settings → Maps & Modes → Default-Pawn-Class = 'None…
Then use Gamemode → BeginPlay → ‘Spawn Actor from Class’ → Pawn Reference…
That way you also directly control the spawn-point which can catch you out sometimes…
If this isn’t Multiplayer, you can stick with Pawn / Gamemode / Player-Controller / Widgets.
You can handle nearly all possible Inputs using Pawn only (do away with PlayerController)…
GameInstance helps if you need Persistence. Never used GameState/PlayerState, sorry!
Thanks for sharing that franktech, I had suspected I was getting a default pawn because of that setting, but I actually didn’t tried to Null it so I wasn’t sure, good to know