move to actor distance and clone collision help

Game Editor comments and discussion.

move to actor distance and clone collision help

Postby J Slayer67 » Sun Jun 10, 2007 5:39 pm

is there any way to have an actor collide with it's clone and only make the enemies move towards the charecter at a certain distance (like if the actor was n close enemy move to player) but also have it so that once the player is far enough away, the enemy would stop following the player?

Sorry it's A LOT for one post but some help would be greatly appreciated :D
Zelda junkie!!
A
AA
User avatar
J Slayer67
 
Posts: 44
Joined: Fri Jun 08, 2007 8:40 pm
Score: 1 Give a positive score

Postby pixelpoop » Sun Jun 10, 2007 6:28 pm

Use an "if" statement with a "distance" check on the enemy Draw Actor script.

if ( distance(x, y, player.x, player.y)<40 &&
distance(x, y, player.x, player.y)>5) {moveto(player.x, player.y);}

I haven't tested this but it should work.

EDIT: I changed the > signs.
Last edited by pixelpoop on Mon Jun 11, 2007 11:46 am, edited 1 time in total.
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Postby J Slayer67 » Mon Jun 11, 2007 2:05 am

thx :) ill tell u if it works...do u know how to have 1 actor collide with it's clone?
Zelda junkie!!
A
AA
User avatar
J Slayer67
 
Posts: 44
Joined: Fri Jun 08, 2007 8:40 pm
Score: 1 Give a positive score

Postby pixelpoop » Mon Jun 11, 2007 11:43 am

Do you mean that you want the enemy clones to not overlap while they move to your player? in that case replace the moveto command in the above script with this one:

MoveTo(clonename, 0, 0, 1, "playeractor", "enemyname");

Don't change where it says clonename.
Change the 1 to any velocity you like, although it gets glitchy at higher rates.
Change the playeractor to the name of the actor to move towards.
Change the enemyname to the name of the enemy whose script this is on.

Also, I changed the code in my first post, so check it.
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Postby J Slayer67 » Mon Jun 11, 2007 12:26 pm

thanks i'm not making a very big game but it'll be my first with lvls so i want it to be (some what) cool becuse i might post it here when it's finished. :)
Zelda junkie!!
A
AA
User avatar
J Slayer67
 
Posts: 44
Joined: Fri Jun 08, 2007 8:40 pm
Score: 1 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron