Hi.
Is there a possibility to make an actor to use some of the paths randomly, but not all of them?
I.e. : I've created 6 paths. I want actor A to follow path 1,2 or 3, and actor B to follow 4,5 or 6.
Can it be done?
Thanks.
char pathname[10];
int i=rand(3);
if(i>1){
strcpy(pathname, "uno");
}
else if(i<=1){
strcpy(pathname, "dos");
}
ChangePath("Event Actor", pathname, BOTH_AXIS);
char pathnames[6][10]={"uno", "dos", "tres", "quattro", "cinco"};
int i=round(rand(5));
char thispath[10];
strcpy(thispath, pathnames[i]);
ChangePath("Event Actor", thispath, BOTH_AXIS);
DST wrote:And yes, you can use numbers instead of letters. I just felt like practicing my spanish tonight.
Make sure the length of your char[] array is long enough to hold the word +1 letter.
So the word "yes" requires a char[4] length array (the last character is string termination).
void searchpatrol()
{
char pathnames[3][12]={"patrolpath", "patrolpath1", "patrolpath2"};
int i=round(rand(3));
char thispath[12];
strcpy(thispath, pathnames[i]);
ChangePath("Event Actor", thispath, BOTH_AXIS);
}
DST wrote:rand() generates a number up to and including the number specified. Since your array values are 0, 1, and 2, use rand(2) instead.
int i = rand(3);
Users browsing this forum: No registered users and 1 guest