Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: SFG Leader on Thu 13/12/2007 09:27:13

Title: Scripting problem with moving objects
Post by: SFG Leader on Thu 13/12/2007 09:27:13
When I try and use this script it, the object (a car) doesn't appear but the game continues.
I have the SetTimer command but the script bellow still doesn't work. I have double checked
all the SetTimer variables and the variables below and they all seem to be correct.
All the script below is in the Repeatedly Execute section of my room and the SetTimer
command is in the Player enters room (after fadein) section.

if (IsTimerExpired(2) == 1) {
  oCar1.Visible = true;
  oCar1.Move(318, 234, 3, eNoBlock, eAnywhere);
  oCar1.Visible = false;
  }

Any thoughts on what I am doing wrong will be greatly appreciated.
Title: Re: Scripting problem with moving objects
Post by: Gilbert on Thu 13/12/2007 09:40:17
The problem is, you used "eNoBlock" for the object movement, so the next "...Visible = false" line will be executed immediately after that, so the object will be turned off immediately before moving.

Depending on your needs, suggested solutions are:
1. Change the movement to eBlock; or
2. If you don't want the movement to be blocking but don't mind the object to stay on screen, just remove the "...Visible = false" line; or
3. If you don't want the  movement to be blocking and still want the object to disappear after moving, in your case you may revise the codes as:

if (IsTimerExpired(2) == 1) {
  oCar1.Visible = true;
  oCar1.Move(318, 234, 3, eNoBlock, eAnywhere);
  }
if (oCar1.Moving==0) oCar1.Visible = false;

Title: Re: Scripting problem with moving objects
Post by: Khris on Thu 13/12/2007 18:41:14
Or, since you're using eAnywhere, just move the car off the screen.
oCar1.Move(320, ...);
Right?
Title: Re: Scripting problem with moving objects
Post by: Terrorcell on Thu 13/12/2007 21:06:19
Yes, it works now.

Thanks.