I’m trying to create a game where you control a team of characters all at once. The idea is there is one “main” character that acts as a sort of pivot for the other characters that follow them. The player can change the shape of the formation on the fly.
So my current line of thinking is this:
I have a single player actor, surrounded by anchor points (the white cubes for now) that the other team characters will track, and move into position of these cubes to stay in formation.
My current set up is really slap dash right now. I feel like I have the barest, brute-force pieces there.
I don’t have it working, I’m looking for solutions.
Hello,
It all depends on what the uncontrolled characters (those in the white cube positions) need to do.
I recommend using a Behavior Tree that will move the character to a position. As Auran13 said, it is best to use offset vectors. You can create a set of tasks, decorators, and services. For example, a task that assigns the offset vector based on its position in the formation, then a service that updates the destination to wait for (player location + offset) that you place on a MoveTo task. To simplify things, to define a character’s position in the formation, you can use an IntPoint type variable that gives you 2 integers that you can use as the X index and Y index in the formation.
If your characters are just following your player in a military unit context (I get the impression that’s what you’re trying to do), you can also add them directly to ChildActorComponents (instead of white cubes, you put child actor components containing the character).
You put a SceneComponent for each character, and a child actor component in each scene component. At runtime, using AttachComponentToComponent, all you have to do is assign the right child actor component to the right scene component to change formation.
I really prefer to try and build this with Blueprints for the time being. I’m more art/animation focused.
To clarify what I’m trying to do: you control the whole party at once technically. Think in terms of Zelda: Four Swords Adventures, or in a more abstract sense, think of each of the surrounding team-mates as those little mobile sentry / “options” in space shooter games like Gradius and R-Type. The following functions are what I’m currently looking to implement at this moment:
Formation Switching: such as to a “Star” Shape, to a “Line Shape”, or any other formation I have currently planned.
Lead Position Swapping: Taking one character in the group and shifting them to the first position, or barring that, cycling which of the teammates take lead.
Whichever character is in the lead, has the ability to attack or use special skills in the game, as sort of the “acting” character. For now let’s keep it to that.
As for the nav-mesh, I think it has some merit to the idea, but I want to get the formation switching, and figure out how well having effectively 5 (six really) characters on screen all at once is going to read in game before going any further.