Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: J.E.S. on Tue 16/09/2008 06:10:44

Title: Change player view depending on location...(Solved)
Post by: J.E.S. on Tue 16/09/2008 06:10:44
Why does this code work...


function hBedroomDoor_Interact()
{
if(Character.GetAtScreenXY(90, 210)==cSlade)
{
  player.ChangeRoom(2, 200, 265);
}
else if (player.View==2)
{
  player.ChangeView(1);
  player.Walk(90, 210);
}
else
{
  player.Walk(90, 210);
}

}



But this code doesn't...



function hSladesCouch_Interact()
{
  if(Character.GetAtScreenXY(210, 260)==cSlade)
  {
    player.ChangeView(2); //to sit on couch
    SetWalkBehindBase(1, 200);
  }
  else
  {
    player.Walk(210, 260);
  }

}



I want the script to check the position of my character before he can sit on the couch. If he is close enough he will be able to sit on the couch when it is clicked again. This code works fine when I want to change rooms and I also like the freedom of walking without eblock.
Title: Re: Change player view depending on location...
Post by: Creator on Tue 16/09/2008 09:25:28
Create a region (around the couch) and when you interact with it (the couch) use:

function hSladesCouch_Interact() {
if (Region.GetAtRoomXY(cSlade.x, cSlade.y) == region[1]) {
   player.ChangeView(2); //to sit on couch
    SetWalkBehindBase(1, 200);
  }
  else {
    player.Walk(210, 260);
  }
}


Easiest way I could think of.
Title: Re: Change player view depending on location...
Post by: J.E.S. on Tue 16/09/2008 09:49:11
Thanks Creator, that did work. I'll mark this one as solved.