Player pawn is none after open Level

I made a Level called MainMenu that also loads a Widget Called MainMenu. In this MainMenu Widget, if you press “Start Game”, it loads the FlatGrass Map. The Map loading itself works. Also the correct Player Pawn Controller “RtsPawnController” is loaded.

Just the RtsPawn which was set inside the GameMode used for the FlatGrass Level seems not to be loaded correctly by the Engine… it is “None” if I try to get its Reference inside the RtsPawnController.

Have I introduced some flaw I am not recognizing?

You need to look at the node after the cast to find out if it worked.

I just constructed this whole arrangement and it works fine.

Thanks for your fast Reply :-).

What I can say is: the return of the Cast also gives None.

If I load the FlatGrass Map directly in the Editor and press Play, it works like a charm…

Here’s a Breakpoint with a Watcher at the return of “Cast To RtsPawn”

Here’s A Debug Log of Blueprint activities Afterwards. The “Pawn Ref” is definitely “None”.

If you think there’s specific information Missing. please tell me. I am fairly new to Unreal, so maybe I missed something.

What I mean is:

the break point needs to be on the next node if you want to look at the ref.

I suspect it’s not casting.

If it fails, do this to find out what it really is:

Seems the Casting is not the Problem. It is already damned to fail in front of the Casting. GetPlayerPawn gives already “None”.

Could this be a problem with Input Modes?

326284-debugprintf.jpg

Right. What kind of BP did you make? It’s easy to leave out pawn or character if you start making custom types…

  • For the MainMenu Level I made a “GameMenuGameMode” with Parent Class “Game Mode”:

  • For the Game Levels I made a “RtsGameMode” with Parent Class “Game Mode”

  • The “RtsPawn” Blueprint has “Pawn” as its Parent Class. It contains A sphere Mesh with SpringArm Mounted Camera.

  • The “RtsPawnController” Blueprint has “Player Controller” as its Parent Class. It contains Rts Like Controls.

In your Pawn Blueprint, do you have the controller set to Auto Possess on Spawn/Placed in Level?
(meant to make this a reply)

Also check what ConradG is saying…

Yeah, it is a possession Problem. Forgot to put a Pawn inside the “GrassLevel” and did not know I need to either possess the Pawn by AutoPosess at the Pawn Class Settings or some Blueprint scripting etc.

If I directly Play the Map inside the Editor, it seems the Editor injects a Pawn automatically at the actual View position…

Is this all normal behavior?

Now it seems my Input Events inside the “RtsPawnController” do not trigger anymore.

326364-pressftopayrespect.jpg

If I start the “FlatGrass” Level directly the Inputs are triggered without Problem. Don’t know if this problem has kind of the same Root… Should I open a new Question for this?

It’s the same problem. You’re not getting a pawn for some reason.

If you F8 ( exit during gameplay ), what do you see in the outliner?

Yes to above - normal behaviour…

But: the whole point of having a game mode and changing the game mode for the level is you don’t need to put a pawn in the level…

After pressing F8 during gameplay:

326380-outliner.jpg

Did you enable input in the pawn? Did you toggle ‘consume’ off?

326405-screenshot-6.jpg

I have no Controls inside the Pawn. my Controls are all set inside the PlayerController. is this the wrong way to go? Did fetch this way to go from a Youtube Tutorial.

here’s my Controller Blueprint (Rts style Camera Movement):

Hi, I have found a way to solve it, and it is crazily simple.

Just

1.turn your parent class of your game mode to Game Mode Base

2.turn your parent class of your game state to Game State Base
That is all.

At least, it works for me.

Good luck!

This reply is really late but if it helps anyone in the future, This is most likely because you have set input mode UI only when displaying the widget to the viewport for the main menu but forgot to set the input mode to Game and UI/ Game only where you are doing the open level node.

1 Like