Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Mouth for war on Wed 25/02/2009 21:06:29

Title: having my character disappear when object is animating.[SOLVED]
Post by: Mouth for war on Wed 25/02/2009 21:06:29
Ok! Here's my problem...when my character reads a spell in a book an object starts animating...no problems there...but when that smokeanimation reaches frame 3 i want the character to disappear. I looked through the forum but couldn't find an appropriate answer. This doesn't quite work
Here's when the animation starts...could someone please help? :)

object[3].Visible = true;
object[3].SetView(5, 3);
object[3].Animate(3, 2);
if (object[3].Frame!=2) {
"Character disapperars"
Title: Re: having my character disappear when object is animating.
Post by: Matti on Wed 25/02/2009 21:40:01
Quote from: Mouth for war on Wed 25/02/2009 21:06:29
object[3].Visible = true;
object[3].SetView(5, 3);
object[3].Animate(3, 2);
if (object[3].Frame!=2) {
"Character disapperars"

Why do write "Frame!=2" instead of "Frame==3" ? In this case he would disappear right at the beginning of the animation, doesn't he?
Title: Re: having my character disappear when object is animating.
Post by: Mouth for war on Wed 25/02/2009 22:15:07
i tried to type frame = 3 too but nothing happens until the animation is finished...and i want it to happen on frame 3 as i said
Title: Re: having my character disappear when object is animating.
Post by: Dataflashsabot on Wed 25/02/2009 22:17:41
it has to be "frame==3". note the two equels.
Title: Re: having my character disappear when object is animating.
Post by: Matti on Wed 25/02/2009 23:23:38
You have to write object[3].Animate(3, 2, eNoBlock);

..because eBlock is the default and thus the script will be stopped until the animation is finished.
Title: Re: having my character disappear when object is animating.
Post by: Mouth for war on Wed 25/02/2009 23:43:52
This is what it says now...it's another thing...i want it to play a sound instead when the animation plays frame 10 but it doesn't work

// room script file
function room_AfterFadeIn()
{
Wait (50);
object[0].Visible = true;
object[0].SetView(5, 3);
object[0].Animate(3, 0, 1,  eNoBlock);
if (object[0].Frame!==10) {            (Parse error in expr near object)
PlaySound (3);}
object[0].Visible = false;
cEgo.Transparency = 0;
}
Title: Re: having my character disappear when object is animating.
Post by: Matti on Wed 25/02/2009 23:51:22
You wrote !== instead of just ==.
Title: Re: having my character disappear when object is animating.
Post by: Mouth for war on Thu 26/02/2009 00:01:17
function room_AfterFadeIn()
{
Wait (50);
object[0].Visible = true;
object[0].SetView(5, 4);
object[0].Animate(4, 2, 1, eNoBlock);
if (object[0].Frame==10) {           
PlaySound (3);}
object[0].Visible = false;
cEgo.Transparency = 0;
}

Now the animation don't even play :( just skips to everything after that
Title: Re: having my character disappear when object is animating.
Post by: Khris on Thu 26/02/2009 00:12:05
AGS doesn't wait, every command is executed right away.

function room_AfterFadeIn()
{
Wait (50);
object[0].Visible = true;
object[0].SetView(5, 4);
object[0].Animate(4, 2, 1, eNoBlock);
}

bool done;
// create this function using the room's event pane
function Room_RepExec() {
  if (!done && object[0].Frame==10) {
    PlaySound (3);
    object[0].Visible = false;
    cEgo.Transparency = 0;
    done = true;
  }
}


Title: Re: having my character disappear when object is animating.
Post by: Mouth for war on Thu 26/02/2009 00:18:23
function room_RepExec()
{
if (!done && object[0].Frame==10) {
    PlaySound (3);
    object[0].Visible = false;
    cEgo.Transparency = 0;
    done = true;
  }

Error line 13 "undefined symbol done" I'm quite new to this scripting stuff as you can tell :)
Title: Re: having my character disappear when object is animating.
Post by: Matti on Thu 26/02/2009 00:35:03
You have to declare variables. In this case "bool done;" like KhrisMUC wrote.
Title: Re: having my character disappear when object is animating
Post by: Mouth for war on Thu 26/02/2009 01:43:34
ah missed that...thanks :D works now