Making my custom PlayerController posses my Pawn on spawn

Hey guys.

I cannot for the life of me, figure out how to make my customer PlayerController auto possess my Pawn. Here’s my scenario:

  • I have custom PlayerController (RTS_PlayerController)
  • I have a Pawn (RTS_Camera)
  • I have my custom GameMode (RTS_GameMode)
  • I have a custom GameState (RTS_GameState)
  • And I have a custom GameInstance (RTS_GameInstance)

In my project settings, under “Maps and Modes”, I’ve set the following settings:

  • Default GameMode - RTS_GameMode
  • Default Pawn Class - RTS_Camera
  • HUD Class - None
  • Player Controller Class - RTS_PlayerController
  • Game State Class - RTS_GameState
  • Player State Class - PlayerState (default)
  • Spectator Class - SpectatorPawn (default)

I’m not quite sure how to make my PlayerController auto possess my Pawn, and I fear that this has something to do with these modes settings that I don’t quite understand?
Help and ideas are much appreciated :slight_smile:

EDIT 1
Placing another pawn into my scene, I can see that this pawn gets auto possessed by my player controller, however, my Event Begin Play event is not hit. What could cause this, and why doesn’t this happen?

EDIT 2
Further investigating I noticed that if I remove the execution of my input events (see image below) the pawn DOES NOT move at all, so those events are being hit. Still not understanding why my begin play event isn’t hit.

If you edit your custom GameMode, is your custom character controller and custom pawn set as the defaults? Are the world settings of the Map you are loading also using your custom GameMode? The GameMode you select in Maps and Modes can be overridden by your map’s world settings.

I have everything set up correctly in my GameMode. My player controller and my pawn is all set to my custom classes. In the world settings I’m not overriding my gamemode. It’s just set to “None”

You set Auto Possess in the Pawn BP itself.

Hey, sorry for the long delay. I’ve set the “Auto Possess Player” property to “Player 0” on the BP itself. Doesn’t seem to make any change though.

What do you see in the outliner if you play in the viewport?

Sorry, outliner? What do you mean?

He means the top right window in Unreal where it shows actors in the level. Is your custom pawn in the level? or only the default pawn? If its the default pawn then your custom pawn is not being spawned. If your custom pawn is in there, it means its being spawned but not possed by your custom player controller

Ah of course. Well, it is there.
tmp1.PNG

EDIT
It adds another camera in the scene though:, called CameraActor. This seems like some default camera it throws into the scene. Remember, the controls work fine, and it DOES posses my camera, but my EventBeginPlay is not being hit. That’s my main problem. I can navigate with WASD as expected, but the begin play is not triggered.

not sure in that case, show a picture of your begin play nodes, alternatively try putting a delay set to 0.2 right after event begin play incase it is trying to be fired before possession

Tried adding the delay, but to no avail. Here’s an image of my begin play event:

Thats an unusual Create Widget node, is this inside your Pawn or Player Controller? What is the RTS pin at the bottom of the create widget node? Try adding a Print String to the end to see if the BeginPlay is firing at all.

What is the red dot at the top left of the node also? I havent seen that before

The read dot is just a debugging point, as I wanted to try and debug my way into this :slight_smile: Unfortunately, this is never hit. It doesn’t make sense to add a print string to the begin play because, as mentioned, the debug point isn’t hit at all, therefore the Event BeginPlay is never triggered.

What’s wrong with my Create HUD widget? I’ve just implemented an interface as I need to controller and the pawn inside my widget :slight_smile:

Ahhh ok, sorry I hadnt seen that debug point before I will look into that. Could maybe try putting it into the construction script instead because this will definitely be fired since your pawn is spawned

Thankyou franktech, Detilium already covered that, we learn a new bit of unreal engine everyday! Sorry I couldnt help more Detilium. Good Luck!

Yes this is the pawn blueprint. I tried adding the event tick and tried debugging, however this is never triggered as well. This is exactly the same problem as the begin play.

Could you perhaps guide me in spawning the pawn in blueprints? I can’t seem to find anything online, or at least I can’t make it work :slight_smile:

I haven’t been able to find anything in my project that should be overwriting the auto possess or spawn. Everything looks as it should. The problem started when I decided to create my GameState BP. Could that have something to say? That’s at least when I started messing with my world settings.

It was the default, so perhaps?

I found the problem.

After hours of research, I came across this AnswerHub question. It’s not 100% the same problem, but the same issue with the BeginPlay event not being triggered was present for him as well.

My customer GameState class had the “GameState” parent class, but as my custom GameMode class has the “GameModeBase” parent class, it wouldn’t work. After changing the GameState to have parent: “GameStateBase” solved my problem, and my BeginPlay event is now being triggered.

I had no idea that the GameModeBase had to be combined with the GameStateBase and no the regular GameState, for this to work.

Well, you need to learn something new every day correct? :slight_smile:

Thanks for your help franktech and Orkney