Controlling a pawn with player controller, im losing my mind

So I’m an artist at heart, but I’m giving this a go because it’s fun, but I can’t for the life of me get my head around it.
So I have a Player Controller Blueprint with this ‘move forward’ action:

it references a blueprint interface that goes to my pawn character:

that recieves the command and should move forward…
But nothing happens. I’ve set the gamemode up and my pawn sits there in front of me in game, so the game mode works, but nothing fires in the blueprint, no red dots travel along the lines and nothing happens…
halp? am i doing something horribly wrong?
I tried doing the same but with a character instead of a pawn, and I got some physics actions to work, but still none of MY inputs did anything…

It doesn’t look like you are sending it to the controlled pawn, but instead calling move forward on the controlling itself. Get a reference to the controlled pawn, cast it to your pawn class and then call move forward on it.

Your MoveForward in the first picture is not an interface message. It’s just calling a function in your controller called MoveForward. The “Target Is BP Controller” text tells you that it’s not targeting the pawn. Also Interface messages have a little letter icon at the top right.

But there’s no real reason to be using an interface for this in a Player Controller, because Interfaces are mainly used when you do not know what class you will be sending the event to. Is that the case, or are all your controllable pawns of the same class?

If so, you can just (in your controller) **GetControlledPawn -> Cast to your pawn class -> Call a function/event **(create a custom event instead of your Interface “Event Move Forward” event).

If you only have one character and you never switch between different characters, you can simplify this even further and just have the InputAxis MoveForward event directly in your pawn. As long as** Auto Receive Input ** is on in your pawn’s default settings, it will receive input events (but make sure to either remove **InputAxis MoveForward **from your controller, or set it as non-consuming, otherwise your controller will get the input first and consume it).

A-ha! Thanks, you’re right, I was calling a function instead of sending the interface a message. This fixed it:


But yes, this project of mine will (hopefully) involve controlling different pawns, so I need to be able to switch between them. Is this the right way to go about that?

If your different pawns will be of different classes, yes. If they will simply be different instances of the same class, interfaces are not necessary. You can just cast the GetControlledPawn to your pawn class and call functions directly.

Even if you have different pawn classes, ideally they should inherit from the same base class, so you can just cast to that base class and have the functions present in that base class. Especially for things that for sure will be common/shared functionality like movement.

Ah right, yes parented classes are probably better. So this is what I’ve come up with-

The master pawn blueprint takes an event input and sets the velocity of a static mesh variable:


The child pawn blueprint has a static mesh component, and in the construction script sets the variable from the parent to that mesh:


and the controller listens for the control input and passes it to the controlled pawn:

You can do the second step in the parent class construction script as well. If your parent has a “static mesh” var and the static mesh component and sets it up in the construction script, all your children have to do is change the static mesh variable in their defaults.

That way you don’t duplicate code on multiple children, so it’s a lot easier if you have to change or expand that functionality on all your children at once later.