alarm problemes
#1
Posted 13 August 2012 - 02:39 AM
i m trying to make a simple AI for an ennemi
it has to move a certain distance to the right/left (hspeed =+-4),
than stops (hspeed = 0);
choose to go right or left a certain distance, stops etc.
when it stops (hspeed = 0) an alarm is triggered to choose left/right and calculate the distance to go;
the problem is: the alarm event is not triggered when hspeed = 0;
so my hspeed stays equal to 0.
and my variable" a" does not change from the one calculated in the "create event"
here is the code
event create
facing = 1;//facing right
a = x+random(room_width-x); //random distance to move to the right
event step
if facing == 1 //moving right
{
if(x<a) hspeed = +4;
else {hspeed = 0;alarm[10]=30;}
}
else
if facing == -1 //moving left
{
if(x>a) hspeed = -4;
else {hspeed = 0;alarm[10]=30;}
}
alarm10 event
facing = choose(+1,-1);
switch facing
{
case +1 : a = x + random(room_width-x); //move right
case -1 : a = x - random(x); //move left
}
i don't understand where the problem lies thks for helping me
#2
Posted 13 August 2012 - 02:49 AM
Edited by willowvayle, 13 August 2012 - 02:49 AM.
#3
Posted 13 August 2012 - 02:53 AM
? I don't know if these are your problems but... Wouldn't hspeed be set like 'hspeed += 4' not 'hspeed = +4'?
no
the problems is with this alarm that doesn't work
#4
Posted 13 August 2012 - 03:00 AM
#5
Posted 13 August 2012 - 03:41 AM
that's the problem the alarm event
Edited by mihashi, 13 August 2012 - 03:41 AM.
#6
Posted 13 August 2012 - 04:36 PM
EVERY STEP
Change your conditional so that doesn't happen.
#7
Posted 13 August 2012 - 06:20 PM
Simple solution.
Instead of using:
alarm[10]=30;
Use
if (alarm[10] == -1) alarm[10]=30;
#8
Posted 13 August 2012 - 06:25 PM
#9
Posted 13 August 2012 - 06:29 PM
#10
Posted 13 August 2012 - 06:30 PM
Good luck on your project.
Don't be afraid to ask more questions.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











