Download

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.
ac9f4f3c60afc18e3b9ac428f5f689617b730814.png

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.
7a6a1ecc980b3f80dae5cc6d285f72c1b6807c9c.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:
55991b934b0c7e3aed7e423e3cdf70ba759058f9.png

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

CreateWidget looks normal (‘Expose on Spawn’ exposes an RTS var).

Its just a breakpoint to stop execution / test the code is being hit…
When debugging its essentially the same as a Print String node etc.

BeginPlay just shows HUD setup. Where’s Possession in any of this…
What’s that Blueprint anyway, maybe its actually never being called.
Add manual CreatePlayer / Possess nodes to show what’s going on???

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

Gotcha sorry, must have scrolled past Detilium’s reply the first time round.

So you’re passing in Pawn/PC references… Something about the built-in functions didn’t work?

Get Owning Pawn
Get Owning Player…

So this is the Pawn blueprint then (self etc)? Stick a breakpoint on Tick too, re-check the BP…
Or manually create Pawn Spawn in Gamemode, just in case you are overriding it somehow…

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:

The forums aren’t so useful at walking someone through this tbh.
In your shoes I’d take a step back and look at a Working project.
Any of the free FPS templates should do or this one by Jacky etc.