Moving the Character's Group in Formation

Hello,

I have a group made by the main character of the game and some other secondary characters met along the way.
I’m making the secondary characters follow the main character using this blueprint.


The problem is that using this blueprint, the secondary characters move as a crowd.

Crowd.jpg
Instead, I’d like to move them as a formation where each character takes a well-defined spot (for example, a diamond-shaped formation where the main character is at the head of the group, 2nd and 3rd characters behind him and the 4th character at the bottom).

Any idea on how to accomplish that?

Thank you in advance!

1 Like

hi man,
You have to define the position of the formation , that can be done using vectors only, but get tricky,
so here i used some scenecomponents to make the shape of the formation,
so its easier to define , and than save the reference to the scenecomponents in an array.
I used the location stored in the array to draw a debug sphere, you should call the movetolocation for your AI, one for every formation point.

You can also store the Relative location of these formation in simple Vectors and remove all the scenecomponents once you designed them.
You have to do some vector works to place the coordinates relative to the player too.
Well its some work to do, hope this help you to start

2 Likes

That’s awesome! Thank you very much for the detailed answer! It’s of great help.

Can I ask you a detail, please? How do you say to a specific pawn to move to a specific position in the formation? When you call “Get Controlled Pawn” you get all the controlled pawns, don’t you?

1 Like

Well, i am not sure but every pawn should ask to the player where is his “formation location”
as you have seen i made an array out of the formations so every pawn should be sure of his place in the team , lets say you have 4 panws
Add a variable inside and set it to 1,2,3,4.
So you can :
Cast to the player OR make the player say to the pawns
Which position should every member take.
So Pawn 1, will ask for Formation_location N1
So Pawn 2, will ask for Formation_location N2

Here a video about ai movement that i found useful

2 Likes

Perfect, thank you! I really appreciated your help. I’m sure I’ll be able to build everything in the right way thanks to everything you told me :slight_smile:
Have a great day!

1 Like