Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: hocuspocus on Tue 16/06/2020 20:31:50

Title: Problem with Checking Character.Moving in an If-Statement
Post by: hocuspocus on Tue 16/06/2020 20:31:50
Hi, I'm fairly nee to AGS. I have a character that moves, and when she's done moving I want a GUI to appear. Here's the code:
Code (ags) Select

gText2.Visible = false;
cClient1.SetWalkSpeed(6,  6);
cClient1.Move(500,  720,  eNoBlock, eAnywhere);
if (cClient1.Moving == false) {
    gText2.Visible = true;
}


I'm trying to check if the character stopped moving in the if-statement, but it's not working. The character does move but nothing happens when she stops. I tested it with another character that doesn't move at all, and the GUI does show up. What am I doing wrong?
Title: Re: Problem with Checking Character.Moving in an If-Statement
Post by: Crimson Wizard on Tue 16/06/2020 21:30:34
Try this instead:
Code (ags) Select

while (cClient1.Moving) {
    Wait(1);
}
gText2.Visible = true;


This will keep looping until Moving becomes false.
Wait(1) is necessary to let engine update and redraw the game (otherwise it will stuck in script forever).
Title: Re: Problem with Checking Character.Moving in an If-Statement
Post by: hocuspocus on Wed 17/06/2020 19:42:31
Thanks, it worked!
Title: Re: Problem with Checking Character.Moving in an If-Statement
Post by: Khris on Sat 20/06/2020 14:42:47
If blocking the game is fine, you can simply use  eBlock  instead, I guess?