Page 1 of 1

enemys walking off the edge...

PostPosted: Wed Jul 21, 2010 5:39 am
by pizbi
how do I make an enemy turn around before it falls of a edge? :?

Re: enemys walking off the edge...

PostPosted: Wed Jul 21, 2010 6:19 am
by Hblade
I was also wondering the same thing :o

Re: enemys walking off the edge...

PostPosted: Wed Jul 21, 2010 7:34 am
by savvy
you could try putting little canvas' on the edges so that when the enemy touches them it turns around.

Re: enemys walking off the edge...

PostPosted: Wed Jul 21, 2010 10:06 am
by Hblade
oh good idea :D Or a filled region to prevent lag :3

Re: enemys walking off the edge...

PostPosted: Wed Jul 21, 2010 11:53 am
by Game A Gogo
Code: Select all
if(CollisionFree("Event Actor",x,y+2)==0)
{
    //Turn around script here, Here's what it could be?
    ChangeAnimation(///);
    xvelocitty=-xvelocity;
}


Hope this helps :)
This might not work all the time; if there are actor that do not have the Collision State set to Disable (It's a function) and goes under the character, well it'll turn around as well

Re: enemys walking off the edge...

PostPosted: Wed Jul 21, 2010 2:50 pm
by pizbi
thank you thank you! :D

Re: enemys walking off the edge...

PostPosted: Wed Jul 21, 2010 3:14 pm
by Game A Gogo
if you want the enemy to change sides also when he encounters an objects on the left/right (So he doesn't hit them)
simply change the line
Code: Select all
if(CollisionFree("Event Actor",x,y+2)==0)
to
Code: Select all
if(CollisionFree("Event Actor",x,y+2)==0||CollisionFree("Event Actor",x-2,y)==0||CollisionFree("Event Actor",x+2,y)==0)

Just trowing this in :)

Re: enemys walking off the edge...

PostPosted: Wed Jul 21, 2010 3:35 pm
by jimmynewguy
Sgt. Sparky was a genius. viewtopic.php?f=6&t=3600

Re: enemys walking off the edge...

PostPosted: Wed Jul 21, 2010 5:43 pm
by Hblade
He was.. one of the smartest kids I known

Re: enemys walking off the edge...

PostPosted: Thu Jul 22, 2010 1:35 am
by krenisis
Wow jimmy 2006? how long you been here? jimmytheoldguy lol!!

Re: enemys walking off the edge...

PostPosted: Thu Jul 22, 2010 3:19 am
by jimmynewguy
i used GE for about 6 months before i joined the forum so almost 4 years actually :lol:

Re: enemys walking off the edge...

PostPosted: Thu Jul 22, 2010 8:08 am
by Hblade
:D same here :3

Re: enemys walking off the edge...

PostPosted: Thu Jul 22, 2010 9:25 am
by DST
Filled regions aren't a good idea for doing this because you will have to place them on every single platform that is to have an enemy on it.

Then, editing your game becomes much much slower. You'll find you have to change platform positions for all sorts of reasons to make your levels challenging yet playable.

One thing you can do is with a cloned platform, is collision>topside>platform>repeat no>
int twidth=(collide.width/2)-(width/2);
xlimit1=collide.x-twidth;
xlimit2=collide.x+twidth;

Then in enemy>draw actor>, just have the enemy walk between the two points.

Re: enemys walking off the edge...

PostPosted: Fri Jul 23, 2010 2:38 am
by pizbi
DST wrote:Then in enemy>draw actor>, just have the enemy walk between the two points.

how?