I followed the thread I linked before (Is it possible to use both AI Controller and Player Controller with the same pawn?), did some experiments and got it working. Now I have a “Semi Player Controller” and “Semi AI Controller” both influencing my Character.
What was missing from the instructions in the thread:
- Your “Semi Player Controller” should, in the Event On Possess method:
a) spawn a “Semi AI Controller” and hold it as a variable
b) spawn the Character and possess it with the “Semi AI Controller”
c) switch camera to the one in Character, by using Set View Target with Blend - Create events to receive input in the “Semi AI Controller”. Then invoke them when you receive actual input from “Semi Player Controller”.
- Camera will break… So far the only way to fix it I found is to:
a) in “Semi Player Controller”: Auto Manage Active Camera Target = OFF
b) in “Semi AI Controller”: Set Control Rotation from Pawn = OFF, and on tick (yeah…) you need to Set Control Rotation to match the Camera (not camera boom!) rotation
c) in Character: Inherit Pitch/Yaw/Roll in Spring Arm (camera boom) = OFF, Component Replicates = ON
d) when you want to rotate you need to rotate the camera boom instead of using the controller methods (because the pitch method will NOT work in AIController, see unreal engine4 - UE4 How to set pitch in controlRotation for AIController - Stack Overflow)
I think that was all. Then you can run a behavior tree and pass your input as a bool, which you immediately have set back to false in a behavior tree task before performing an action, otherwise it will just loop. Passing axis values (movement, camera) to a behavior tree seems impossible, because the parallelism is very limited and one action would block the other.
I’m going to keep building on top of that and see if there are any issues down the line, but so far it works (even in multiplayer).