clone help (again) =P

Non-platform specific questions.

clone help (again) =P

Postby Imperialjester » Mon Jan 17, 2011 5:01 pm

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;
User avatar
Imperialjester
 
Posts: 185
Joined: Wed Dec 08, 2010 5:39 pm
Score: 10 Give a positive score

Re: clone help (again) =P

Postby skydereign » Mon Jan 17, 2011 11:05 pm

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;
    }
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: clone help (again) =P

Postby Imperialjester » Wed Jan 19, 2011 12:08 am

thanks so much :D i will add to your score
User avatar
Imperialjester
 
Posts: 185
Joined: Wed Dec 08, 2010 5:39 pm
Score: 10 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest