So we will be able to send it some basic orders. These are more or less a minimal needed methods for our ABaseCharacter whatever interfaces are needed.īool MoveToWorldLocation(FVector worldLocation)
#Unreal engine 4 player controller code
Now we will build a base class for our characters that we will be controlling them from our PC - we will define some basic functionality: //Remark the code to be threated more like a pseudo code I am no where around UE4 and have no any compilers handy here.Ĭlass ABaseCharacter public ACharacter, IAttackable //. We will use the SpringArmComponent to handle Zoom in/out if needed.ĪCameraPawn will be the PlayerPawn a pawn that is possessed by the PCĪnd the PC will move it around as a whole AActor for the in SceneCamera navigation. The CP will be anything than just a simple setup for a free RTS like camera lets try to describe it and its functionalities. In this scenario a PC will not be possessing any ACharacter directly, it will have it's free APawn let's call it a CP (for camera pawn). I will not get in to too much code here - as it will take quite a lot but I will try to expand on UE4's specific and a general controls:ġ) A "GOD" PlayerController (PC for short): Then Process the input inside your player controller - and delegate the commands to your characters. You make a "GOD" player controller - that will have its own Pawn let's say some sphere with an arm and camera attached to it. Generally speaking if you want to control multiple characters in UE4 with a free Camera (like IIRC was in BG).