Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   In Need of A.I. code !!!!! (http://www.alice.org/community/showthread.php?t=3274)

 CallowGenius 10-27-2009 09:42 PM

In Need of A.I. code !!!!!

what i have:
-a few enemies
-a protagonist character
-an object representing a piece of technology

what i need (thats where you come in):
-the enemies are constantly trying to obtain the tech
-however, if the enemies come within 2 meters of the protagonist, and the player presses space, the enemy moves backwards 3 meters.
-the enemy shakes off the daze, and continues to get the object
-when the enemies reach the tech, they carry it back to a hole.
-if the protagonist comes within 2 meters of them, and presses space, they scatter 3 meters away leaving the object.
-once the protagonist touches the tech, he wins. with the enemies stopping where they are, and the protagonist lifting the tech in his mighty glory.
:confused:

i need help with the aliens obtaining and dropping the tech, and with the space press and stuff. please help.

 x2495iiii 10-27-2009 11:11 PM

Try something like this for the alien's movement:

While alien is at least .5 meters from tech and daze == false
Alien move .05 meters duration 0 seconds towards tech

Tech set vehicle to alien
Alien turn to face hole

While alien is at least (hole's width) away from hole
alien move .05 meters duration 0 seconds towards tech

And this for when the player hits space:

If player is within 2 meters of alien
daze set value to true
alien move 3 meters away from player duration .5 seconds
else
do nothing

Then add a "when a variable changes" event which looks like this:

if daze == false
do nothing
else
wait 3 seonds
daze set value to false

Now, you'll have to write this code out yourself, copy the alien movement method to all three aliens, and there may be a few things you need to change to make it work smoothly (that's where YOU come in). If you have any other questions though, feel free to ask.

 xxledzeppelin2x3 11-01-2009 05:49 PM

nice job x2495, that is one great and easy to understand explanation :)

 CallowGenius 11-01-2009 10:27 PM

[QUOTE=x2495iiii;12606]Try something like this for the alien's movement:

While alien is at least .5 meters from tech and daze == false
Alien move .05 meters duration 0 seconds towards tech

Tech set vehicle to alien
Alien turn to face hole

While alien is at least (hole's width) away from hole
alien move .05 meters duration 0 seconds towards tech

And this for when the player hits space:

If player is within 2 meters of alien
daze set value to true
alien move 3 meters away from player duration .5 seconds
else
do nothing

Then add a "when a variable changes" event which looks like this:

if daze == false
do nothing
else
wait 3 seonds
daze set value to false

Now, you'll have to write this code out yourself, copy the alien movement method to all three aliens, and there may be a few things you need to change to make it work smoothly (that's where YOU come in). If you have any other questions though, feel free to ask.[/QUOTE]

How do I set those values to false/true? why are they values? Im creating them as methods. Should they be functions?

 x2495iiii 11-01-2009 11:54 PM

Oh. I'm saying you should create a boolean variable which is named something like daze, dazeTrue, or something like that, then have that variable set its value to true when the daze method is called, and false when its done.

 All times are GMT -5. The time now is 11:13 AM.