Move Objects In a Pattern

I’ve just started working on a strategy game. Currently when I move the troops they move just fine but they get jumbled up and don’t stay in their current formation. How do I make them stay in a certain formation like a square or triangle or something?

IDK how to exactly do it

But i know you can do something like separation of moving objects with

But idk if it is possible ot keep all objects in same exact formation

A formation might be difficult but not impossible. You could pick a leader and then either stick the other objects with the sticker behavior to the leader or save the difference between them and the leader as an object variable. You would then set their position x and y as leader x + object.Variable(offsetX)

The problem would be handling obstacles or attacking other objects. It would depend on how you’re moving the objects. You might want to have 2 modes. One for in formation and one for not breaking away and fighting.

I played with the concept in the past using a pathfinder object. I was trying to get the troops to form around the player. So, instead of targeting the player. It was targeting spots around the target.

In your case, if you’re using the pathfinder then the leader could target an object and the other instances could target their offset x,y to the leader.

A picture might help. I want to try this. I’d love to see them go from formation, though a gap between 2 obstacles and then back into formation.


Thanks for the help.
I managed to fix the problem now. It’s working just fine.

1 Like

Good to hear. Your project inspired me. Keeping them in formation works with the sticker. I tried the x,y variable method until I wanted to rotate the group. I then switched to setting object variables for distance and angle from the leader. I then used put around another object and added the leader’s angle to their angle. This also works but for turning using the pathfinder behavior it looks odd. The pathfinder turns too sharply and it looks unnatural. They’re currently just circles, so until I decide what they represent, IDK how they should turn. The turns need to be larger and smoother.

If anyone’s curious, I can start a new thread or post when I either suceed or see something shiny and do something else.

1 Like