| Welcome to Brackenwood. We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
- Pages:
- 1
- 2
| Basic A.I | |
|---|---|
| Tweet Topic Started: Feb 28 2006, 05:08 AM (403 Views) | |
| clayt | Feb 28 2006, 05:08 AM Post #1 |
![]()
I'm not crazy... ask my toaster!
|
hey, im looking for some Basic A.I on a little game that im making. What i need is: - the enemie will like patrol so he will be walking left to right. - when the player gets close to the enemie the enemie will attack. - if u move away he will stand still untill ur more close again and he will then attack. - and if i attack he dies - and i want all these to be sprites so it will be like 'gotoandPlay(die);' etc... Thanks if anyone can help me out! :lol: What i have so far on the Enemie is:
Which is really crap to be honest lol... And whats on the Player is:
Thanks again if anyone can help me! |
![]() |
|
| crumb | Feb 28 2006, 07:38 PM Post #2 |
|
Rufum Ru Sudily!
|
lol, why is my name in your script?
|
![]() |
|
| bracks | Feb 28 2006, 11:53 PM Post #3 |
|
Brackenwood Lightweight
|
you could try a macromedia tutorial |
![]() |
|
| smoscar_01 | Mar 1 2006, 12:01 AM Post #4 |
|
Mid-Level ActionScripter
|
ok most of the time in games like mario or those, an enemie has a patrol at a platform it means that he will go from left to right (as you pointed out) the best thing to do that is making transparent wall objects in wich if the enemie touches it he will change its direction. You can achieve that with something like this:
so this way you just need to add some transparent walls and that will work, maybe you would want some flying enemies that goes up and down, you just need to change the _x propertie for _y and add your transparent walls :lol:
now the enemie needs to be checking the character position and if he is near then he will go towards him (I didnt thought of any other way of attack :lol: ). So we already have an onEnterFrame event so we can add our new code there
so in this case the enemie will go towards the character until he finds a transparent wall, we are adding 1 to speedx cos we want it to look like he is running
I was thinking that in most of the games the enemie keeps moving even if he doesnt sees the character, maybe you meant that he stands there a few seconds waiting if the character returns right? well it is best seen if he trys to catch you until he cant for example jump something (a transparent wall would be there)
well all the above code had to be at the enemie code, but now we want our character to attack, an action related to our character. I dont know if he shots or what he does so Ill assume that always that he attacks the enemie will die
and at enemie's frames we'll need to have a frame called dying and at the end of the dying animation (optional) we'll have our deleting enemmie code
In case he shots and that the enemmie can dodge or something reply it please
...done hahaha maybe I didnt get something clear so please point it out if that happened |
![]() |
|
| clayt | Mar 1 2006, 04:20 AM Post #5 |
![]()
I'm not crazy... ask my toaster!
|
lol... because it was going to be where the enemie 'munches' on the character (eats him)... lol... and munch was the first thing that came into my mind lol. Thank Smoscar... but oh god i hate AS lol... nothing ever works! :angry: When the enemie is patroling he just moves the left becuase 'slide = 0;' when he hits the wall he just carrys on moving And the attack i already had working but the enemie wont die if i dont code it to like i have put...
But it doesnt work, can you help me out please Cheers
|
![]() |
|
| smoscar_01 | Mar 1 2006, 05:32 AM Post #6 |
|
Mid-Level ActionScripter
|
and by that you mean that even if the enemie is chasing the character, he will immediatly return?? and that you want the enemie waits for him a few seconds??
try with _root.enemie.gotoAndPlay("dying"); and check your spelling in the frame name :lol: |
![]() |
|
| clayt | Mar 1 2006, 05:39 AM Post #7 |
![]()
I'm not crazy... ask my toaster!
|
No... the enemie just patrols left to right then when i get near he attacks me lol... sorry if i wasnt clear... your questions was kinda confusing so ill just tell u what i need lol.
i did do it with '_root.enemie.gotoAndPlay("dying");' and it doesnt do any thing thats why i added 'if (bullet.hitTest (enemie)){' lol.... so i dunno what to do. Can you still help me out? Or are you stuck like me? |
![]() |
|
| smoscar_01 | Mar 1 2006, 05:59 AM Post #8 |
|
Mid-Level ActionScripter
|
are you writing this code inside a object?? I you are then try this
this will work <edit> no... wait...sorry
|
![]() |
|
| clayt | Mar 1 2006, 06:05 AM Post #9 |
![]()
I'm not crazy... ask my toaster!
|
Ok cheers, i will try it out and no im not putting the code inside and object.. its on a MovieClip.
Ok i will try that in a sec, but can you tell me what this part is doing:
|
![]() |
|
| smoscar_01 | Mar 1 2006, 06:10 AM Post #10 |
|
Mid-Level ActionScripter
|
lol a MovieClip is an object pal (movieclips, graphics, buttons...)
:lol:
what you are doing in the code above is get this interval x>= enemies position - 9 and x<= enemie's position so lets say that '#' is the enemie sprite and '$' is the character sprite $ ---------# if $ approaches the lines (that equals nine) then # sees him :lol: you tell -9 because you want the enemie to attack you when you are at a distance of nine of him |
![]() |
|
| clayt | Mar 1 2006, 06:17 AM Post #11 |
![]()
I'm not crazy... ask my toaster!
|
hehe i know yeah... i thought you meant as in side the movieclip like on a frame thats inside the MC lol.. sorry :worry:. Oh god... this is so frustrating... could you take alook at the file n see if you can tell me whats going wrong cuz i cant work it out thanks alot Ive attached the file! No i havn't cuz i can't attach files lol.. do you have MSN or Email addresse and ill send it you? |
![]() |
|
| smoscar_01 | Mar 1 2006, 06:19 AM Post #12 |
|
Mid-Level ActionScripter
|
yes men send it to smoscar.01@gmail.com Ill have to go dinner cos my brother is at town, but when I get home Ill send it to you or do you have msn?? |
![]() |
|
| clayt | Mar 1 2006, 06:23 AM Post #13 |
![]()
I'm not crazy... ask my toaster!
|
ok cheers... yeah i have MSN my email is clayt_12345678910@hotmail.com add me if want to!
I have to go for a meeting for work in about 15 mins and i will be back about 11 o clock if you dont live in the UK that would be in 2 hours i will send you the file then. |
![]() |
|
| smoscar_01 | Mar 1 2006, 06:32 AM Post #14 |
|
Mid-Level ActionScripter
|
ok Ill hurry then :lol: |
![]() |
|
| clayt | Mar 1 2006, 06:34 AM Post #15 |
![]()
I'm not crazy... ask my toaster!
|
hehe ok cool
:lol: Have a nice dinner!
|
![]() |
|
| smoscar_01 | Mar 1 2006, 08:03 AM Post #16 |
|
Mid-Level ActionScripter
|
ok I havnt received your email
|
![]() |
|
| crumb | Mar 1 2006, 08:57 AM Post #17 |
|
Rufum Ru Sudily!
|
lol... because it was going to be where the enemie 'munches' on the character (eats him)... lol... and munch was the first thing that came into my mind lol. [/QUOTE] yes forgot it was a common word |
![]() |
|
| clayt | Mar 1 2006, 09:34 AM Post #18 |
![]()
I'm not crazy... ask my toaster!
|
I know sorry i had to dash didnt want to be late for my work meeting ya see lol I will send it now!
Ha ha yes... indeed... its kind of a funny lil' word isnt it lol...he he
|
![]() |
|
| smoscar_01 | Mar 1 2006, 10:54 AM Post #19 |
|
Mid-Level ActionScripter
|
OK clayt Ive already sent it to your email :lol: |
![]() |
|
| clayt | Mar 2 2006, 04:49 AM Post #20 |
![]()
I'm not crazy... ask my toaster!
|
ok cheers... thanks alot... its working accept for the attack and for the enemie to attack lol |
![]() |
|
| smoscar_01 | Mar 2 2006, 09:55 AM Post #21 |
|
Mid-Level ActionScripter
|
Its good that it helped you
:lol: the enemie attack choice is up to you
|
![]() |
|
| pez | Mar 2 2006, 10:52 PM Post #22 |
|
Brackenwood Lightweight
|
this isn't an AS-related tip but thought i'd point it out anyway, it's spelt enemy
|
![]() |
|
| smoscar_01 | Mar 3 2006, 12:17 AM Post #23 |
|
Mid-Level ActionScripter
|
no pez the name of the enemy its enemie
hahaha it was my mistake english is not my first language :lol: |
![]() |
|
| clayt | Mar 3 2006, 02:15 AM Post #24 |
![]()
I'm not crazy... ask my toaster!
|
ok cool.... so how do i do that then? sorry if im asking too much but i dont know an awful lot of AS. |
![]() |
|
| bracks | Mar 3 2006, 07:49 AM Post #25 |
|
Brackenwood Lightweight
|
this tread is interesting :rolleyes: ...is there a way to script a more real AI?? |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| Go to Next Page | |
| « Previous Topic · Actionscript · Next Topic » |
- Pages:
- 1
- 2







5:11 AM Jul 12