0

Hi guys,
As the title says i have 3 boids, all given a number (0,1,2)
by way of i=0, i<3,i++

Later on i'm assigning a certain boid to turn red when it gets within range of it's target boid.

At the minute its only turning red when it comes within range of 1 of the other 2 boids.

At present its set up to read it's target as: [1-i] (Because it's number 1)
If i change it to [i+1] to registers the other boid.

Basically is there a way to check both of these, or possibly all other ?

Thanks in advance.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by sfuo
0

If you want to check all the "boids" against each other but not themselves then you can use this.

int main()
{
	//BOID boid[3]; no idea what data type/structure you are using
	for( int i = 0; i < 3; i++ ) //the boid index you want to compare to the others
		for( int c = 0; c < 3; c++ ) //the boids being compared to
			if( i != c ) //if the indices do not match (not the same boid)
			{
				//do your distance check/setting color in here
				/*
				if( boid[i].IsInRangeOf(boid[c]))
					boid[i].SetColor("Red");
				*/
			}

	return 0;
}

I put in some functions that are pretty much just there to tell you where you can do your changes but I have no idea how you have set your program up.

Edited by sfuo: typo

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.