How to make patrol enemies?

You must understand the Game Editor concepts, before post here.

How to make patrol enemies?

Postby pizbi » Sat May 28, 2011 1:12 am

hi I'm making a game and I'd like to know how to make an enemy that wanders around an area aimlessly.
but the enemy only moves on an x axis
User avatar
pizbi
 
Posts: 37
Joined: Thu Jul 08, 2010 3:36 am
Location: oregon
Score: 7 Give a positive score

Re: How to make patrol enemies?

Postby schnellboot » Sat May 28, 2011 10:24 am

alright here's a quick demo
I didn't comment so ask if you don't understand something
good luck
Attachments
patrol.rar
(2.02 KiB) Downloaded 341 times
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: How to make patrol enemies?

Postby savvy » Sat May 28, 2011 11:56 am

can use x positioning, when they're created set an actor variable to their x position, then make a variable to define what direction theyre traveling in. form this you can map out their movement and restriction.

create actor ->
Code: Select all
originalx = x;


draw actor ->
Code: Select all
if(direct==0)
{x+=2;}
if(direct==1)
{x-=2;}
if(x<originalx-200)
{direct=0;}
if(x>originalx+200)
{direct=1;}


this code will make it move left to right 200 pixels from where it spawned :D
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: How to make patrol enemies?

Postby schnellboot » Sat May 28, 2011 11:59 am

savvy it's kinda the same I posted ^^
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: How to make patrol enemies?

Postby savvy » Sat May 28, 2011 12:15 pm

didn't download it XD
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: How to make patrol enemies?

Postby sunnybubblegum » Fri Jul 15, 2011 5:53 pm

Thank you for posting this. I also needed an enemy on patrol duty.

However, I was wondering how you would add a pause at each end of his patrol. For example, 'walks right, pauses and looks around, walks left, pauses and looks around, repeat'.

Thanks in advance!
sunnybubblegum
 
Posts: 19
Joined: Thu Jul 07, 2011 7:09 pm
Score: 0 Give a positive score

Re: How to make patrol enemies?

Postby schnellboot » Fri Jul 15, 2011 6:19 pm

what do you mean with look around
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: How to make patrol enemies?

Postby sunnybubblegum » Fri Jul 15, 2011 7:49 pm

I thought it might add something if after the enemy stopped, he then faced up for a few seconds, then down for a few seconds, before continuing his patrol in the other direction. As though he's on the lookout for intruders. Does that make sense?

*I'm making a top-down game, by the way.
Last edited by sunnybubblegum on Fri Jul 15, 2011 7:57 pm, edited 1 time in total.
sunnybubblegum
 
Posts: 19
Joined: Thu Jul 07, 2011 7:09 pm
Score: 0 Give a positive score

Re: How to make patrol enemies?

Postby schnellboot » Fri Jul 15, 2011 7:56 pm

do you want me to implement the look script or just the pause
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: How to make patrol enemies?

Postby sunnybubblegum » Fri Jul 15, 2011 7:58 pm

Implementing the look script would be helpful to me, if it's not too much trouble.
sunnybubblegum
 
Posts: 19
Joined: Thu Jul 07, 2011 7:09 pm
Score: 0 Give a positive score

Re: How to make patrol enemies?

Postby schnellboot » Fri Jul 15, 2011 8:51 pm

sunnybubblegum wrote:Implementing the look script would be helpful to me, if it's not too much trouble.

well, I did the wait here
I added two comments where you can put your look script
I couldn't make the look script because I don't have the sprites and I don't know what you exactly want
I think you can do this on your own
Attachments
patrol.rar
(3.09 KiB) Downloaded 207 times
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: How to make patrol enemies?

Postby sunnybubblegum » Fri Jul 15, 2011 9:46 pm

I just put the script onto my intended enemy and it's working well! I didn't realize timers would be involved, but this is a good introduction for me. I still have to make him look around but hopefully that won't be beyond my level. Much thanks for your help and generosity!
Attachments
patrol.png
Here is my patrol with the new code. He seems very scary now!
sunnybubblegum
 
Posts: 19
Joined: Thu Jul 07, 2011 7:09 pm
Score: 0 Give a positive score

Re: How to make patrol enemies?

Postby schnellboot » Fri Jul 15, 2011 10:28 pm

just an example
Attachments
patrol.rar
(2.77 KiB) Downloaded 179 times
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: How to make patrol enemies?

Postby sunnybubblegum » Fri Jul 15, 2011 11:45 pm

That is almost exactly how he's behaving now. Only I achieved it by adding 6 new cases to the switch function you made. One for facing down (4), ahead (5), up (6), and the same on the other end (7, 8 and 9). They each have their own timers and animations. I don't know if this is a very economic way to do it, but it's working so far.

My next challenge is giving him the ability to spot and then chase you if he's facing you. But I think I'll give my ambition a rest for a minute! :D
sunnybubblegum
 
Posts: 19
Joined: Thu Jul 07, 2011 7:09 pm
Score: 0 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron