clone help

Non-platform specific questions.

clone help

Postby Imperialjester » Sun Jan 09, 2011 5:49 pm

hello every one i have a problem. im trying to make my actor stop when close to a clone but i dont want to make a code for each clone i have. is there a way i can make it so that it stops when my actor gets close to any clone right now my code is
Code: Select all
if(distance(x, y, wall.x, wall.y) >= -1){
    if(dir == 1){
 
        ChangeAnimation("Event Actor", "PlayerIdleRight", NO_CHANGE);
 
         dir=3;}
 
 
 
 
 
    if(dir == 2){
        ChangeAnimation("Event Actor", "PlayerIdleLeft", NO_CHANGE);
 
         dir=3;}


problem is it only stops at the original clone
User avatar
Imperialjester
 
Posts: 185
Joined: Wed Dec 08, 2010 5:39 pm
Score: 10 Give a positive score

Re: clone help

Postby schnellboot » Sun Jan 09, 2011 6:00 pm

so what is the clone?
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: clone help

Postby Imperialjester » Sun Jan 09, 2011 6:06 pm

the wall is the clone but i have 2 i want it to be able to stop at the 2nd clone not just the first one but i dont want to have to make a new code for each clone.
User avatar
Imperialjester
 
Posts: 185
Joined: Wed Dec 08, 2010 5:39 pm
Score: 10 Give a positive score

Re: clone help

Postby schnellboot » Sun Jan 09, 2011 6:39 pm

Well the code given is not the code for stop right?
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: clone help

Postby Imperialjester » Sun Jan 09, 2011 6:48 pm

it is, let me explian my code. when my actor's x position is reletive to -1 of wall's x position dir =3 if dir = 3 x+=0 x-=0
User avatar
Imperialjester
 
Posts: 185
Joined: Wed Dec 08, 2010 5:39 pm
Score: 10 Give a positive score

Re: clone help

Postby schnellboot » Sun Jan 09, 2011 7:04 pm

hm.. it should work for both walls cuz you didn't use cloneindex
could I see the ged?
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: clone help

Postby Imperialjester » Sun Jan 09, 2011 7:49 pm

ok i removed my old code and changed it a little im still haveing a problem i will show you mmy whole code for that actor
this is in my enemys draw actor
Code: Select all
if(Army1.x  > x + 320){
Enemycover=0;
EnemyShoot=0;}
if(Army1.x  < x - 320){
Enemycover=0;
EnemyShoot=0;}
if (EnemyShoot==1){
CreateTimer("Event Actor", "enemybullettime", 900);}

if(EnemyShoot==0){
DestroyActor("EnemyBullet");}


if(EnemyHealth<=0)
DestroyActor("Event Actor");




 


if(Enemycover == 1){
if(wall.x  > x + 1){
x+=2.6;}
if(wall.x  < x - 1){
x-=2.6;}
                   }


 
EnemyShoot=1;
Enemycover=1;

if(wall.x  > x + 320){
Enemycover=0;}
if(wall.x  < x - 320){
Enemycover=0;}


this is for my squad commander game and i dont ant to post the .ged until im ready to release v0.2 i am not using clone index
User avatar
Imperialjester
 
Posts: 185
Joined: Wed Dec 08, 2010 5:39 pm
Score: 10 Give a positive score

Re: clone help

Postby skydereign » Sun Jan 09, 2011 9:41 pm

The problem is that you are using name.variable. You can't specify the clone you are accessing, in these cases wall and Army1. You'll have to get the Actor*s for the clones, and use that to check the variables. To do this though, you'll have to setup a loop checking all wall's xy coordinates. If this event is in a collision event, then you won't have this problem because you can use collide.variable instead of name.variable, which is a precise representation of the current wall.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: clone help

Postby Imperialjester » Sun Jan 09, 2011 10:02 pm

ok, how do i do that? :|
User avatar
Imperialjester
 
Posts: 185
Joined: Wed Dec 08, 2010 5:39 pm
Score: 10 Give a positive score

Re: clone help

Postby skydereign » Mon Jan 10, 2011 1:33 am

Here's one of several posts explaining getCloneIdx, a derivative of the getclone2 function. Use it to get the Actor* of the wall, to check the x coordinate.
Code: Select all
int i;
Actor* currentWall;
for(i=0;i<ActorCount("wall");i++)
{
    currentWall=getCloneIdx("wall",i);
    if(wall->x > x+1)
    {
        //
    }
    else if(wall->x < x-1)
    {
        //
    }
}


This is a short example of how you might implement it. Typing this out makes me think it isn't optimal, but without more information on what you are doing, I can't really make it that much better.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: clone help

Postby Imperialjester » Mon Jan 10, 2011 3:35 pm

thanks for all the help but i dont have a function called getcloneidx and i have the newest version of GE
User avatar
Imperialjester
 
Posts: 185
Joined: Wed Dec 08, 2010 5:39 pm
Score: 10 Give a positive score

Re: clone help

Postby Bee-Ant » Mon Jan 10, 2011 4:55 pm

Here's my version of code...
Code: Select all
int i;
Actor *check;
char str[32];

for(i=0;i<ActorCount("wall");i++)
{
    sprintf(str,"wall.%i",i);
    check=getclone(str);
    if(distance(x,y,check->x,check->y)<10)
    {
        //stop action here
    }
}
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron