Problem with Checking Character.Moving in an If-Statement

Started by hocuspocus, Tue 16/06/2020 20:31:50

Previous topic - Next topic

hocuspocus

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

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?

Crimson Wizard

#1
Try this instead:
Code: ags

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).


Khris

If blocking the game is fine, you can simply use  eBlock  instead, I guess?

SMF spam blocked by CleanTalk