Adventure Game Studio | Forums

AGS Support => Beginners' Technical Questions => Topic started by: Melkoroth on Wed 10/01/2018 20:46:09

Title: How to set interact distance ?
Post by: Melkoroth on Wed 10/01/2018 20:46:09
Hi everybody.

Im creating a game as a school assigment and i choose this program to be my engine.

But im having a problem now. I created a room in a painting software, and in AGS a made a hotspot over than door and i want the player to change the room when he interacts with the door.
Everything works only that the player can click on the door from any distance to change to room. I would like to know how to create a hotspot or a object and set a distance from which it can be interacted with.

Thanks
Title: Re: How to set interact distance ?
Post by: Matti on Thu 11/01/2018 09:32:12
Do you really only want the player to allow to interact with the door when they stand next to it or do you just want the character to walk to the door before opening it? If it's the latter then you can just set the WalkToPoint in the door hotspot's property pane. Alternatively you could code it yourself using a blocking walk command:

Code (ags) Select
function hDoor_Interact()
{
  player.Walk(282, 173, eBlock); // or whatever the coordinates should be
  player.ChangeRoom(6);
}
Title: Re: How to set interact distance ?
Post by: Melkoroth on Thu 11/01/2018 14:17:22
Quote from: Matti on Thu 11/01/2018 09:32:12
Do you really only want the player to allow to interact with the door when they stand next to it or do you just want the character to walk to the door before opening it? If it's the latter then you can just set the WalkToPoint in the door hotspot's property pane. Alternatively you could code it yourself using a blocking walk command:

Code (ags) Select
function hDoor_Interact()
{
  player.Walk(282, 173, eBlock); // or whatever the coordinates should be
  player.ChangeRoom(6);
}


Thank you ! This was exactly what i was looking for.