How do you access pawn data via the Player Controller

I need my player controller to issue a command to a pawn. I want to press a key and add force to the pawn which is a physics object. I don’t know of the channel of communication between player controller and pawn, how to access and manipulate the pawns data from the player controller blueprint.

Hey there @deijardon! Welcome to the community! So you can have your inputs on your pawn itself or you can have them on the controller and pass them down, but inputs already pass through to the controlled pawn as is.

But to answer your original question, you can use the Get controlled pawn node if you ever want to communicate between player controller and controlled pawn other than passed through inputs.

Hope this helps!

1 Like

Hi! Thanks for the reply. Im not sure this fits my scenario. I am trying to control a physics object with physics forces. I have a ball that I want to apply a force to. I need the player controller to fire an impulse to a radial field in the level that will affect the physics object. I dont want to directly possess the ball (actor). I need to control the environement from the player controller. I assumed I would be able to simply drop the actor on the player controller blueprint and get a reference to that actor but this does not work.

I think casting is what I might be looking for…Im not sure.

I hope I understand your question correctly. The player controller actually is for controlling the player pawn. AI Controllers are used for NPCs. But this means, they are possessed by these conrollers. If I understand correctly, you just want to take influence on some other actor/pawn (the physics object) that is placed or spawned in the level, but is not the player or some NPC.

So this does not necessarily be done by the player controller, could even be just be done by the player character or somewhere else. You just need to get a reference to that object, so for example GetActorOfClass can be an option. Those Get(All)ActorsOfClass operations should not be done too often, like every tick, because they are quite expensive, but for example getting that reference for later use in BeginPlay is a good option.
Now you can run any functions on that Pawn.

Yes, this is the solution. So I get the actor of class, then I get the component of class, the physics object and manipulate from there. Great…Thank you.

Click on the “Solution” button then!! :slight_smile: