Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Eric on Sun 04/03/2012 17:10:22

Title: Mirror character walk to object too?
Post by: Eric on Sun 04/03/2012 17:10:22
I have a room with a mirror, a tiny room, in which I have a hole cut in a walk-behind through which the mirror character appears. I've put together code from a few sources on the forums, condensed, because my walk area is so small I don't really need to do extensive measuring from the bottom of the mirror to make the effect work (you can see a picture of the room in an image at the bottom of this thread (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=45456.msg610755)).

Here's what I have:

function room_RepExec()
{
cFelixReflection.x=player.x+35;
cFelixReflection.y=player.y-20;

cFelixReflection.Frame = player.Frame;
 int l = player.Loop;
 if (l == 0 || l == 3) l = 3 - l;
 cFelixReflection.Loop = l;
}

I also have some objects in the room, for instance, a set of drawers, that the player walks to before opening, so:

player.Walk(oFelixDrawer1.X,oFelixDrawer1.Y,eBlock,eWalkableAreas)

When I interact with the drawer, the player walks to it as I'd hoped for. Unfortunately, the mirror character does not, and creepily stands there before disappearing once the drawer is opened. Any suggestions on getting mirror man to follow?
Title: Re: Mirror character walk to object too?
Post by: WHAM on Sun 04/03/2012 17:14:59
The walk is a blocking script and this keeps the Repeatedly Execute from working. Look in the manual for "repeatedly execute always" and try having the mirror script posted here in that instead. As far as I can understand that should work.

EDIT: Something like this in the room script

function repeatedly_execute_always() {
  cFelixReflection.x=player.x+35;
  cFelixReflection.y=player.y-20;

  cFelixReflection.Frame = player.Frame;
  int l = player.Loop;
  if (l == 0 || l == 3) l = 3 - l;
  cFelixReflection.Loop = l;
}

Title: Re: Mirror character walk to object too?
Post by: Eric on Sun 04/03/2012 17:58:05
Quote from: WHAM on Sun 04/03/2012 17:14:59
EDIT: Something like this in the room script

That works like a charm. Thanks very much!