Skip to main content
GameDev.net gamedev.net
🔒 Locked

Keeping spaceships apart

Started by appel Jun 25, 2009 at 9:01 AM 2 replies 650+ views
Original Post
appel
appel
I'm making a space based RTS game (2D). There are bunch of space ships that the player controls, e.g. he selects them and orders to move to some new location. Now, when the spaceships arrive at the new location I want to put some space between them. It's OK that they overlap each other while traveling, but not when stopped. What's a simple way to accomplish this? (I have no physics system.)
Luckless
Luckless
Several options. When you group a set of units, assign one as a lead, and sort the rest. Then develop a method of simple formations.

+++1+++
++2+3++
+4+5+6+
7+8+9+10

Or something similar.

That, or pick a leader/head of the 'flock' and write a sorting method that will let the other ships find their own open slots around the leader. Each would find the closest open space near the leader.
Old Username: Talroth
If your signature on a web forum takes up more space than your average post, then you are doing things wrong.
appel
appel
Quote:
Original post by Talroth
Several options. When you group a set of units, assign one as a lead, and sort the rest. Then develop a method of simple formations.

+++1+++
++2+3++
+4+5+6+
7+8+9+10

Or something similar.

That, or pick a leader/head of the 'flock' and write a sorting method that will let the other ships find their own open slots around the leader. Each would find the closest open space near the leader.


I'm not really looking for flocking.

All spaceships move from A to B, in euclidean space, linearly, equally.
Once a spaceship arrives at B, stops, then the game should ensure that overlapping spaceships are somehow kept apart.
Halifax2
Halifax2
Quote:
Original post by appel
Once a spaceship arrives at B, stops, then the game should ensure that overlapping spaceships are somehow kept apart.

That's exactly what Talroth solved for you. Have all your ships move linearly and equally from A to B, then have them stop. Assign all the ships an ID, sort based on the ID, and then use the ID to implement whatever formation you want.
Denzel Morris (@drdizzy) :: Software Engineer :: SkyTech Enterprises, Inc.
"When men are most sure and arrogant they are commonly most mistaken, giving views to passion without that proper deliberation which alone can secure them from the grossest absurdities." - David Hume

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.