Jump to content
  • Advertisement
Sign in to follow this  
formns

RTS-unit formation

This topic is 2747 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm not native English speaker so that I don't speak English well. Please understand it.

I'm trying making RTS game.
I put units in this game and had them learn to move.
When player right clicks, selected-units go to the point he clicked.

@ How do I determine the position of each unit ?

I implemented a simple formation.
This method is that:
first, I put a "seed" position which is mouse position when I clicked.
second, I make it grow lengthwise.
third, I put two new seed on the left and right of "seed"
forth, I make them grow lengthwise.
... I repeat these until num of selected-unit is exceeded;

but this method doesn't creat standard formation of standard RTS.
I want to know the standard method.
And, these positions of the formation are assigned to units at random,
so that because some units push units which formed a line once aside when they move,
the formation become disturbed.
I also want to know the method to assign units to best positions.

Please lend me a hand[font="osaka,"][size=2].[/font]

Share this post


Link to post
Share on other sites
Advertisement
  • Your assumption that there is a "standard" way to move units in formation in a "standard" RTS game is a bit disturbing. Your formations have to work well in the context of your game: the density, size and shape of your common obstacles, your unit sizes, the typical head count of groups of each unit, the kind of formations that make sense from a tactical point of view, and so on. For example, do you need traveling formations (more or less rigid columns), combat formations (with wide fronts and hopefully protected flanks), or both at different times? Does the player order units to change formations, or only to move to a certain place? Do you want traveling units to spread and move fast, or to clump together and protect the flanks of the formation at the expense of speed? Do you want units in combat to concentrate or to surround enemies?
  • Are you able to move a single unit satisfactorily? Pathfinding to any destination, moving obstacle avoidance, fighting along the way? Reliably sending units anywhere you need is a prerequisite for movement in formation.
  • I don't know what you do with your "seeds", but it is usual to designate a leader unit that simply moves towards the destination (where the user clicked) and have the other units in the group move towards a specific position close to the current position of the leader. This is entirely different from moving the units to a specific position near the leader's destination, which destroys any hope of coordination. Real life example: ducks flying in a V formation, where all but one try to stay a certain distance left or right and behind another duck (two actually follow the leader, the others follow indirectly).
  • Another typical pattern is having each unit decide where it wants to be relative to its closest neighbours in the formation, whoever they might be (usually in order to align and/or spread evenly).
  • If you express your formations as movement destinations for individual units, each unit can take care of its own obstacle avoidance and eventually repair any disruption. Leading units might need to slow down or stop to wait for delayed comrades.
  • Given a requested formation (some starting locations) and a number of units that have to fill it, you can match destinations to units with useful criteria (like assembling the formation as fast as possible or minimizing mutual obstructions) rather than randomly. For example, you can find the unit that is furthest from any formation starting location, match it with the closest starting location (it determines the minimum time to assemble the formation: don't make it worse than it has to be) and process the rest of the units and starting locations without crossing the existing paths (which belong to less favored units).

Share this post


Link to post
Share on other sites
Thank you for kind reply.
I'm sorry if I don't understand your reply well.

OK, there is no "standard" way.
I'll find best way for my RTS game. :-)

Are you able to move a single unit satisfactorily? Pathfinding to any destination, moving obstacle avoidance, fighting along the way? Reliably sending units anywhere you need is a prerequisite for movement in formation.[/quote]
Yes, map of game is made by Graph, units can pathfind with A*algorithm.
and units can avoid obstacles with "steering behavior".


but it is usual to designate a leader unit that simply moves towards the destination (where the user clicked) and have the other units in the group move towards a specific position close to the current position of the leader.[/quote]
"Steering Behavior" has way like this behavior, "Leader Following".
I implemeted this one. But, it didn't work well,
for "other units" only follow them leader, don't follow path,
so that if them leader is in the other side of wall, other units follow leader
so other units rush at wall, never reach them leader.
I think that mutual obstructions are better than rushing at wall.

Another typical pattern is having each unit decide
where it wants to be relative to its closest neighbours in the formation,whoever they might be (usually in order to align and/or spread evenly).[/quote]
Is it like using "Flocking" for units ?
In any event, units which don't know paths will rush at wall.


As you said, If I match destinations to units, units never hit obstacles, walls..
The problem is that :
the position of the formation isn't assigned to "best" unit.
-"best" means closest, for unit and for position.
for example, A is the closest unit for position X, and B is the closest unit for position X, too.
And, A is closer to position X than B.
in this case, position X should be assigned to A,
and B should be assigned to the closest position except position X.
I think that if I use this way, units won't crash another unit and the formation will be assembled fastly.
But I don't have a lot of confidence. Is my idea wrong...?

In addition, I'm sorry I'm shameless, I want to know how I make units go their destination,
I also want to know how I determine the destination for unit as position concretely :-)

Share this post


Link to post
Share on other sites
Are you able to move a single unit satisfactorily? Pathfinding to any destination, moving obstacle avoidance, fighting along the way? Reliably sending units anywhere you need is a prerequisite for movement in formation.

Yes, map of game is made by Graph, units can pathfind with A*algorithm.
and units can avoid obstacles with "steering behavior".
[/quote]

It is clear from the rest of your remarks that your units are in fact unable to avoid some classes of obstacles, and/or that they sometimes go straight without adequate pathfinding.
This won't do; the authority of dumb steering behaviours should be limited to deciding where the unit wants to arrive (then you can apply correct pathfinding to get there), not determining movement directions without consideration for obstacles.

but it is usual to designate a leader unit that simply moves towards the destination (where the user clicked) and have the other units in the group move towards a specific position close to the current position of the leader.[/quote]
"Steering Behavior" has way like this behavior, "Leader Following".
I implemeted this one. But, it didn't work well,
for "other units" only follow them leader, don't follow path,
so that if them leader is in the other side of wall, other units follow leader
so other units rush at wall, never reach them leader.
I think that mutual obstructions are better than rushing at wall.
[/quote]

Steering behaviours that ignore walls and make the unit march straight to its desired location are useless. Instead, you should use your normal A* pathfinding, repeatedly because the destination changes as the leader moves, to avoid walls intelligently.

Another typical pattern is having each unit decide
where it wants to be relative to its closest neighbours in the formation,whoever they might be (usually in order to align and/or spread evenly).[/quote]
Is it like using "Flocking" for units ?
In any event, units which don't know paths will rush at wall.
[/quote]

Different steering behaviour, same problem: you need real pathfinding to avoid walls. Steering behaviours work well only in open spaces, which don't seem to be common in your game.

Your pathfinding needs to take all obstacles into account, both walls and moving objects (like friendly units). Updating the graph with moving objects might be expensive, but you can compute new paths for each unit only periodically (maybe every few seconds) and whenever they need to stop in front of new moving obstacles.

Share this post


Link to post
Share on other sites
Yes, so I never make units move without pathfinding.
To be sure, using pathfinding their leader, units can avoid obstacles.
But, it is not necessary to form while units are moving.
All they have to do is to form when they finished their movement.

Pathfinding is quite a few heavy process,
so to [color=#1C2837][size=2]match destinations to units is better than to pathfinding to leader incessantly, isn't it ?
[color=#1C2837][size=2]

[color=#1C2837][size=2]And, even if I make units follow their leader,
[color="#1C2837"]same problem will happen : I can't match to units best position(offset to leader),
[color="#1C2837"]that units don't hit mutually and as close to it as possible.
[color="#1C2837"]

[color="#1C2837"]Yes, when unit do pathfinding, if unit consider moving-obstacles, unit can avoid other units.
[color="#1C2837"]But, in [color=#1C2837][size=2]commercial [color=#1C2837][size=2]RTS game units get best position - not hit other units at all.
[color="#1C2837"]How do I calculate it ?
[color="#1C2837"]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!