Page 1 of 1

clone help (again) =P

PostPosted: Mon Jan 17, 2011 5:01 pm
by Imperialjester
hi i need more help with my clones i want it so it only moves to somthing if it is within a distance right now my code is
Code: Select all
if(x < check->x+320)
xvelocity=-2.6;

Re: clone help (again) =P

PostPosted: Mon Jan 17, 2011 11:05 pm
by skydereign
To make that code work, you will need to set check to something. And if you want it to check all clones, then you need a for loop. The break is to get out as soon as you determine a target to move to. The ActorCount only works if none of these actors will get destroyed. The abs() call is a way of checking both sides.

Code: Select all
int i;

for(i=0;i<ActorCount("actor");i++)
{
    check=getCloneIdx("actor", i);
    if(abs(x-check->x)<320)
    {
        // move
        break;
    }
}

Re: clone help (again) =P

PostPosted: Wed Jan 19, 2011 12:08 am
by Imperialjester
thanks so much :D i will add to your score