[Help] I'm creating a wheeled vehicle game on Unreal 4's blueprints and I'm trying to access the player pawn's input (which should be 0) but it always reads NULL. Does anyone know how to get my pawn to be of player input 0?

I’ve searched tutorials and all online posts but nothing this specific has been discussed (to my knowledge). The player 0 character should be the wheeled vehicle pawn. The only way i could play the blueprint specifically is by setting the default player class as the pawn blueprint. I’ve been experimenting with speed boosts or jump pads but it requires me to access the player input which always outputs as NULL. Any help is appreciated, thanks!

A pawn’s contoller will be null until the pawn is possessed by a controller.

You can do this a few ways:

  1. Before gameplay by setting a pawn placed in tbe level to be auto possessed by a playercontroller at a specific index.
  2. During gameplay by calling the controller’s Possess function on the pawn.
  3. Some kind of configuration thing i forgot how to do.

Thanks for the quick response! I tried setting a placed in world pawn to receive input from player 0 before but it never works even if I select the default pawn class as none. I’ve also tried the function where you initiate a button press to switch possessions between pawns and that doesn’t work either (at least for me). I’ve seen posts where there are repossessions of pawns but those only work when I can get player input, unfortunately it still prints the player input as NULL.

If you run a GetAllActorsOfClass on your playercontroller class (not the pawn), how big is the returned array?

would I run this in the level blueprint? Is it possible you could show a screenshot of this example please?

The same as in any blueprint. From Beginplay for example, put a delay of 2 seconds just to make sure it is not waiting for something to initialize and then the get all actors of class node after that, the returned array going into a length node which goes into a PrintString node. There now you are logging how many actors it found of your playercontroller class.

Okay so I got the output as 2 when only my spawned character and an AI pawn are on the map.

Interesting. So now you can take that GetAllActors array and loop over it and print out what the PlayerController IDs are of each one.by first doing a Get Controller, then cast to PlayerController, then Get Player Controller ID, then printstring that ID number. See if ID 0 has already been taken by one of the pawns, and which one.

I get these errors if i’m doing this correctly:
Error Blueprint Runtime Error: Accessed None trying to read property CallFunc_Array_Get_Item from function: ‘ExecuteUbergraph_TestWorld’ from node: Cast To PlayerController in graph: EventGraph in object: TestWorld with description: Accessed None trying to read property CallFunc_Array_Get_Item


Error Blueprint Runtime Error: Accessed None from function: ‘ExecuteUbergraph_TestWorld’ from node: Cast To PlayerController in graph: EventGraph in object: TestWorld with description: Accessed None

Are you trying to cast the World to a PlayerController? A playercontroller can’t be the world so that will always fail. I think we should see some screenshots of your code.

Yes that blueprint graph looks quite wrong.
I was about to tell you a list of what to fix but I think it would be more productive to
Ask you for more screenshots of the code you were having trouble with when you first started this thread.
It might be laboring under similar problems and we can just fix them straight away instead of fixing the problem finder code you just posted.

But for your benefit here is the list anyway:

  1. It doesn’t make sense to run the getallactors node every loop. The purpose of the loop is to do sometbing with each thing we find in the array that comes out of that getallactors node which array we wont have until after executing the getallactors node, so to fix it, run that before the loop not inside it, and plug its output into the for each’s input (that is the left side of its node).
  2. The output of a for each loop over an array of playercontrollers is going to be a player controller for each execution of the Loop pin, so it doesnt make sense to Get Instigator then get controller because you already have the controller from the very first being output from that for each node.What youre doing is like saying “get me the owner of that house that belongs to that person.” Instead of just “get me that person”

But like I said I think our time will be better spent looking into the code of the original problem instead.

Okay, this is probably not right so here’s the screenshot.

Thank you~
My original question is how to access player 0 or set my default player pawn as player 0 because whenever i try to access my player pawn that i’m driving around the map it just prints Null or -1 which doesn’t help. btw I try to access my pawn by Get Player Pawn in my pawn blueprint and connect that to a print node.

Also I fixed my code and it appears to work, it labels all other pawns as -1 and my pawn as 0. I’m just having problems trying to get my character to possess and other pawns. I might have to make another thread for this what do you think?

For example when I try to access the character I’m using and launch it I get this error:
Error Blueprint Runtime Error: Accessed None trying to read property CallFunc_GetPlayerCharacter_ReturnValue from function: ‘ExecuteUbergraph_Jump_Pad’ from node: Launch Character in graph: EventGraph in object: Jump_Pad with description: Accessed None trying to read property CallFunc_GetPlayerCharacter_ReturnValue
I know for a fact it works on the FPS I made with bp’s idk why it won’t work with wheeled vehicles.