Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Peegee on Sat 20/11/2021 08:31:26

Title: Action on an inaccessible area
Post by: Peegee on Sat 20/11/2021 08:31:26
Hello, a general question:

I have a character or an area where the player cannot yet access. If I click on it, the player cannot move to the area, but he still does his action, from where he is. How to avoid this?
Title: Re: Action on an inaccessible area
Post by: Creamy on Sat 20/11/2021 09:14:39
You can draw a region in the area where the player character should be to trigger the event.

Then you add a condition when the player click on the hotspot/object/character:

Code (ags) Select
if (Region.GetAtRoomXY(player.x, player.y) == region[1]) {
//perform the action
}

else {
//do something else
}


Or you can simply make the hotspot/object/character non clickable at first and activate it when the new area is accessible.
Title: Re: Action on an inaccessible area
Post by: Peegee on Sat 20/11/2021 11:09:20
Thank you for the answer. I try the first solution (you must not put "player.", Only the positions) but it does not work.
Title: Re: Action on an inaccessible area
Post by: arj0n on Sat 20/11/2021 14:42:36
Quote from: Peegee on Sat 20/11/2021 11:09:20
(you must not put "player.", Only the positions) but it does not work.
You should put 'player.x' & 'player.y', as these two are the player character's positions.
Title: Re: Action on an inaccessible area
Post by: Peegee on Sat 20/11/2021 15:56:38
Yes I put this:    if (Region.GetAtRoomXY(player.228, player.173) == region[7])
But the program doesn't take it.

He takes that well:     if (Region.GetAtRoomXY(228, 173) == region[7])
But that doesn't change my problem.
Title: Re: Action on an inaccessible area
Post by: Crimson Wizard on Sat 20/11/2021 16:22:02
Quote from: Peegee on Sat 20/11/2021 15:56:38
Yes I put this:    if (Region.GetAtRoomXY(player.228, player.173) == region[7])
But the program doesn't take it.

You seem to misunderstand, the proper way was to do literally
Code (ags) Select
if (Region.GetAtRoomXY(player.x, player.y) == region[7])


The point is that you ask engine to check which coordinates player character is at. You don't have to know these coordinates yourself.
Title: Re: Action on an inaccessible area
Post by: Peegee on Sat 20/11/2021 16:39:38
Ok, it works! Thank you.