0
\$\begingroup\$

How do I make two or more characters response to a single user input, in this case a mouse click?

Ideally, I'd like something similar to Baldur's Gate style party control. The only example of multiple character party control I have seen implemented is the BioWare style system.

\$\endgroup\$
  • \$\begingroup\$ Can this be done with blueprints? \$\endgroup\$ – Boneco Sinforoso Jan 10 at 23:46
  • \$\begingroup\$ If you can describe exactly what party control do you want - maybe I can help - from what I remember Baldur's Gate controls are somehow similar to RTS controls ? \$\endgroup\$ – ColdSteel Jan 14 at 9:55
1
\$\begingroup\$

Generally speaking if you want to control multiple characters in UE4 with a free Camera (like IIRC was in BG).

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.

Then Process the input inside your player controller - and delegate the commands to your characters.

EDIT per DMGregory's request

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:

1) A "GOD" PlayerController (PC for short): 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). The CP will be anything than just a simple setup for a free RTS like camera lets try to describe it and its functionalities.

ACameraPawn --SceneRoot ---SpringArm ----Camera

We will use the SpringArmComponent to handle Zoom in/out if needed. ACameraPawn will be the PlayerPawn a pawn that is possessed by the PC And the PC will move it around as a whole AActor for the in SceneCamera navigation.

ABaseCharacter

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.
class ABaseCharacter public ACharacter, IAttackable //... whatever interfaces are needed...
{
    public:
    //... C'tor ... D'tor omitted...
    bool MoveToWorldLocation(FVector worldLocation);
    bool AttackTarget(IAttackable* target);

};

These are more or less a minimal needed methods for our ABaseCharacter So we will be able to send it some basic orders.

Now the PC itself (I will not go into code details here, but will describe a general approach) Note: the player pawn is set in the UE4s settings so no code needed for the setup.

Our PC will consume all Player inputs Keyboard (WSAD) and mouse (left right clicks, scroll whatever else).

So the WSAD will be processed inside the PC itself and all it will do is just set its controlled pawn's world location and rotations - Scroll-wheel will set the length of pawns SpringArmComponent etc.

The PC will hold your ABaseCharacters references TArray (not really matters if they were placed in world all spawned dynamically.

Now on mouse input (for instance Goto World Location) it will iterate the ABaseCharacters TArray and dispatch its MoveToWorldLocation method - of-course then the ABaseCharacters's own AAIController will execute the MoveTo task or whatever implementation based there.

So this is how we defined a "GOD" PC in RTS like style that can control multiple characters.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.