Formation System
by Danny Mejia · in Torque X 2D · 12/04/2007 (9:46 am) · 5 replies
I'm working on a game with Jets. What is the best way to make a formation system. So I can have the jets in a ^ shape, Line, and so on.
I think the hard part will be making the algorithms to from the shape. But I'm not sure if I should put this into a component and add it to a jet or to put this into the gamepad component.
Thanks for any help
I think the hard part will be making the algorithms to from the shape. But I'm not sure if I should put this into a component and add it to a jet or to put this into the gamepad component.
Thanks for any help
About the author
#2
12/04/2007 (12:36 pm)
Hey John that would work if you knew how many jets you would have. But I could have 1-100. So I would need to sets. Like No more than 5-6 jet pre set. So I'm going to try to make the algorithm or die trying.
#3
There are three rules to simulate flocking...
Cohesion - Try to move to the average location of similar units in view.
Alignment - Try to maintain the average heading of similar units in view.
Seperation - Try to maintain a certain distance from similar units view.
You can expand this to define leaders of the group and left and right wingmen. The planes would use their own movement physics to maintain the flock. They could break off from the flock and pursue and enemy/player. Obstacle avoidance was easy to add; ie individuals break from the group then rejoin, or even the group goes single file between obsticals!
I'm excited for you if you can't tell!
Edit: learned to spell obstacle :P
12/04/2007 (12:51 pm)
You are talking about flocking AI! I've written flocking component for TorqueX, but I did't add specific flock shape functionality. Single file lines were acheived by tweakin the flock parameters. V patterns occured naturally sometimes. The basics for this algorithm are all over the web I think. It's not that difficult to implement. There are three rules to simulate flocking...
Cohesion - Try to move to the average location of similar units in view.
Alignment - Try to maintain the average heading of similar units in view.
Seperation - Try to maintain a certain distance from similar units view.
You can expand this to define leaders of the group and left and right wingmen. The planes would use their own movement physics to maintain the flock. They could break off from the flock and pursue and enemy/player. Obstacle avoidance was easy to add; ie individuals break from the group then rejoin, or even the group goes single file between obsticals!
I'm excited for you if you can't tell!
Edit: learned to spell obstacle :P
#5
12/04/2007 (2:16 pm)
I'm working on a air-rts game. I will look into this. Thanks
Associate John Kanalakis
EnvyGames
1. Create a large, clear, 100% transparent image. Call it InvisibleFormation.png.
2. Add it into Torque X Builder as a Material.
3. Edit its Link Points to draw the formation you want
4. Cycle through your list of planes and move them to the link points that make up the formation
Use T2DSceneObject.LinkPoints to get the each link point
Then use T2DLinkPointComponent.LinkPoint.Position to set the destination of your planes
5. When the planes are all in the right location, then Mount the planes to the invisible formation scene object
Now the awesome part...
6. Transfer input control from an individual plane to the invisible formation scene object
Now the player can drive the formation, just like a single plane
This should be a whole lot easier than computing individual positions for each plane. ;)
John K.