I’m trying to understand how pawns are controlled by controllers. I was following the tutorial to setup a c++ pawn (https://docs.unrealengine.com/latest/INT/Programming/Tutorials/Components/2/index.html) and it implements the control logic in the pawn itself. However I would like to create a pawn that could be controlled by either an ai or a player. This probably means using a controller to do it. I’m having difficulty understanding how movement data is passed from one to the other. I’ve found examples for the character class, but I haven’t found anything on controlling the pawn class. Is the controller calling a function in the pawn, is the pawn requesting data from controller? Any information on how the two communicate is what I’m looking for, an example would especially be helpful.
In all kind of approaches, as far as I know, it is clear that the control logic of the Pawn must be implemented on Pawn.
void AMyPawn::SetThrottle(float Axis)
// Control logic goes here
AddActorWorldOffset(GetActorForwardVector() * MyPawnVelocity * Axis * DeltaTime);
Player Input Binding in Pawn
Pawn has a setup function for Player called SetupPlayerInputComponent. This function recieves Player Input by binding PlayerController’s InputComponent’s methods then you must connnect your Pawn’s control logic by using these Axis and Action mappings.