Forum Topic: Need help with basic A.I.

(247 views • 9 replies)

This topic is 1 page long.

<< < > >>
None

kramlack

Reply To Post Reply & Quote

Posted at: 6/13/06 04:04 PM

kramlack EVIL LEVEL 08

Sign-Up: 02/18/06

Posts: 331

So I wanted to put some basic A.I. on my MC character (Gaara). I want him to play an animation when the player (Lee) gets within a certain distance from him. I was wondering if there was a simple code for doing this. All help will be greatly appreciated.
~Kramlack~

Note: I just want him to play the blocking animation, I don't want him to follow the player, just stand and block. Thank you.


None

xWELSHxDRAGONx

Reply To Post Reply & Quote

Posted at: 6/13/06 04:21 PM

xWELSHxDRAGONx NEUTRAL LEVEL 07

Sign-Up: 04/13/06

Posts: 505

distance between 2 movie clips

gap = Math.sqrt(Math.pow(mc1._x-mc2._x,2)+Math.p
ow(mc1._y-mc2._y,2))

and now the a.i.

if(gap<200){
gotoAndPlay(watever)
}


None

phyconinja

Reply To Post Reply & Quote

Posted at: 6/13/06 04:29 PM

phyconinja EVIL LEVEL 25

Sign-Up: 09/18/04

Posts: 2,838

At 6/13/06 04:21 PM, xWELSHxDRAGONx wrote: distance between 2 movie clips

gap = Math.sqrt(Math.pow(mc1._x-mc2._x,2)+Math.p
ow(mc1._y-mc2._y,2))

and now the a.i.

if(gap<200){
gotoAndPlay(watever)
}

what hapends if he gets on the other side?
=P


None

xWELSHxDRAGONx

Reply To Post Reply & Quote

Posted at: 6/13/06 04:30 PM

xWELSHxDRAGONx NEUTRAL LEVEL 07

Sign-Up: 04/13/06

Posts: 505

nuthing, we have poweres in there so there are no negative vlaues, it always returns a posative value of the distance


None

kramlack

Reply To Post Reply & Quote

Posted at: 6/13/06 04:55 PM

kramlack EVIL LEVEL 08

Sign-Up: 02/18/06

Posts: 331

At 6/13/06 04:21 PM, xWELSHxDRAGONx wrote: distance between 2 movie clips

gap = Math.sqrt(Math.pow(mc1._x-mc2._x,2)+Math.p
ow(mc1._y-mc2._y,2))

and now the a.i.

if(gap<200){
gotoAndPlay(watever)
}

That doesn't seem to be working for me, I had to change it up to fit my game and this is the end code I got, but the only thing working is the else statement.

onClipEvent (enterFrame) {
gap = Math.sqrt(Math.pow(Lee._x-Gaara._x,2)+Math
.pow(Lee._y-Gaara._y,2));
}

onClipEvent (enterFrame) {
if(gap<200){
gotoAndPlay(1);
}

else gotoAndStop(2);
}


None

kramlack

Reply To Post Reply & Quote

Posted at: 6/13/06 05:42 PM

kramlack EVIL LEVEL 08

Sign-Up: 02/18/06

Posts: 331

Anyone else?


None

Togukawa

Reply To Post Reply & Quote

Posted at: 6/13/06 06:09 PM

Togukawa LIGHT LEVEL 15

Sign-Up: 06/14/03

Posts: 1,024

The physics major is right :-). Do note that the distance is calculated between the movieclip centers.


None

xWELSHxDRAGONx

Reply To Post Reply & Quote

Posted at: 6/13/06 08:35 PM

xWELSHxDRAGONx NEUTRAL LEVEL 07

Sign-Up: 04/13/06

Posts: 505

no no no, now we must ignore this thread, he has been hand feed the code, if he cant use it now he needs to learn more basic things first.

The code works, we will expian any part of it u cant understand, but try and do sumthing on your own ^^


None

kramlack

Reply To Post Reply & Quote

Posted at: 6/13/06 10:16 PM

kramlack EVIL LEVEL 08

Sign-Up: 02/18/06

Posts: 331

Well, it still doesn't work, but I'll try and find out why on my own I guess, sorry Welsh Dragon, didn't mean to be so nooby I guess, I just really wanted to finish this game, and for those who have tried/have helped out, I thank you, hopefully I'll get this boss battle completed and go on with the game.


None

DJStatika

Reply To Post Reply & Quote

Posted at: 6/14/06 08:39 AM

DJStatika NEUTRAL LEVEL 04

Sign-Up: 04/19/05

Posts: 43

does it have to be less than 200 in any direction? or just horizontally or vertically?


All times are Eastern Standard Time (GMT -5) | Current Time: 07:57 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!