Custom pawn with AI and Player Controller

Hi I wanted to ask how can I create a Pawn that has some specific functions… MoveForward, TurnLeft … which can be called by the PlayerController as well as the AIController and that the AIController would use it in navigation…

Because I want to have the AI the same rules as the player… It doesn’t have to be MoveForward or TurnLeft precisely but something in that sence

EDIT: I understand that AI doesnt use my functions (because it has no way of knowing it)… but I guess the AI is using some functions which I could override in the Pawn maybe? that I could do what I want…

Hey there, the AI doesnt use those functions to move the pawn so unless you create your own AI Move To i’m not seeing a way for both AI and Player to use MoveForward and TurnLeft for movement.

Can anyone explain, what functions does AI use to move pawns via navigation? Cause I have the same problem and still didn’t manage to find the answer. But it seems to be the basics, so it looks quite weird to me, that there are no answers…

well technically the AI does use the use the same functions usually used to move a player character, at least as long as you use acceleration for paths. When using acceleration for paths the AI’s pathfollowing component calls RequestPathMove which in turn calls the same function (Internal_AddMovementInput) as AddInputVector does on the pawn.
When not using acceleration the movements components velocity is set directly by the PathfollowingComponent using RequestDirectMove.

So if you wish to alter how the AI moves along and/or finds a path to move along, look at the PathFollowingComponent. If you wish to change how the actual moving of the pawn is implemented have a look at the movement component. And if you haven’t looked at movement components before, don’t start with the character movement component or you’ll get lost. that class is huuuuge. Look at pawn movement or floating pawn movement to learn how the AI interacts with pawn/character movement

1 Like