AS2 Grouping
Started by: Sawc | Replies: 2 | Views: 401
Jun 30, 2009 12:50 AM #450835
Alright guys, I'm working on a game using as2 (ya, I should be using as3, so what?). Let's say you have a group of ai fish or planes or something, all following one controlled by the player. I need some tips on how to get them to group together and follow without overlapping eachother.
Jun 30, 2009 3:21 AM #450887
You could just have a function that is called by each of those objects, then in the function have the movement controls.
Edit:
Misread.
Just have then
Edit:
Misread.
Just have then
if(this.x > otherobject.x){
this.x +/-= set speed;
}
Then repeat for y, although that will get collisions so then maybe use the distance formulae for the other objects, so that if they are within x distance, their speed changes. Or if they do touch, they stop.
Jul 2, 2009 7:55 PM #452501
Quote from SteyeneYou could just have a function that is called by each of those objects, then in the function have the movement controls.
Edit:
Misread.
Just have then
if(this.x > otherobject.x){
this.x +/-= set speed;
}
Then repeat for y, although that will get collisions so then maybe use the distance formulae for the other objects, so that if they are within x distance, their speed changes. Or if they do touch, they stop.
True that would probably work. I don't need them to not touch, just not completely overlap (aka, 20 fish in one spot, so it looks like one fish).