Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: arj0n on Tue 29/09/2009 21:35:40

Title: Character.Walk
Post by: arj0n on Tue 29/09/2009 21:35:40
I want a NPC (a bird) go from the start position in the room to coordinate B and go back to coordinate A
33,163 is coordinate A, 190,163 is coordinate B
the bird should do this constantly
Somehow the character isn't moving at all.
What am I doing wrong?

Code:

function room_RepExec()
{
cBird.Walk(300,  163, eNoBlock);
cBird.Walk(190,  163, eNoBlock);
}
Title: Re: Character.Walk
Post by: Crimson Wizard on Tue 29/09/2009 22:00:11
It does not move, because, since movement is not a blocking type, second line of script is executed right away, and since bird is already at the destination point, it does nothing.

You can do following:



function room_RepExec()
{

  if (!cBird.Moving)
  {
     if (cBird.x == 300)
     {
        cBird.Walk(190,  163, eNoBlock);
     }
     else
     {
        cBird.Walk(300,  163, eNoBlock);
     }
  }
}


This will only give Bird orders if it is not currently moving (that means - either it hasn't move yet, or just reached its destination).
Title: Re: Character.Walk
Post by: Ethan D on Tue 29/09/2009 22:03:34
Also, since you didn't specify whether it is walkableareas or Anywhere the editor will automatically choose WalkableAreas that also could be a problem.
Title: Re: Character.Walk
Post by: arj0n on Tue 29/09/2009 22:23:31
Thanx Crimson & Ethan!

Crimson:
It didn't work, had to change the second line into this:
if (cBird.x == 190)

Than it still didn't work because of what Ethan said: The bird had to fly into an non-walkable area, so I had to make the whole area walkable in order to let the bird be able to fly.

But now the main character can also walk that way, and that's not what I want to.
I guess I have to let the editor know to use "anywhere" in stea of walkable are or something, but don't know how yet...

EDIT:
allrighty, found it, I should use:

cBird.Walk(400,  163, eNoBlock, eAnywhere);
cBird.Walk(190,  163, eNoBlock, eAnywhere);