Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Kamileon on Thu 05/06/2014 09:42:55

Title: Concerning Objects (Walk-to-points and multiple objects)
Post by: Kamileon on Thu 05/06/2014 09:42:55
I have a few questions regarding objects:
1. Can you make a walk-to-point for an object, like you do for hotspots? I want to make it so if I want to pick up oKey the player has to walk to it first.
2. I currently have 2 objects; oCupboardClosed and oCupboardOpen (when the player interacts with the closed door it switches sprites, appearing open - vice versa). I have also tried to put a new object (oBag) into the cupboard, but only visible when the player has the cupboard open. However, I have encountered a problem - oBag appears behind oCupboardClosed because of its bigger size. Is there a way to move the object in front of oCupboardClosed? Or is there another way to solve this?

If anyone could help that'd be appreciated :)
Title: Re: Concerning Objects (Walk-to-points and multiple objects)
Post by: Khris on Thu 05/06/2014 10:22:17
1. Asked and answered many times already. Basically: there are no walk-to points for objects, but given the sprite size and position/baseline you can calculate where the bottom center is. You might also want to use this (http://www.adventuregamestudio.co.uk/forums/index.php?topic=36383.msg477380) to make the walk to the object non-blocking.

2. Size has nothing to do with it; whether object A appears before object B is a question of the y coordinate or baseline.
First of all: ideally, the room background shows an open cupboard. Then a door object is added, which simply changes its sprite when interacted with, alternating between two aligned sprites showing the open and closed door. This also allows animating opening/closing the door. Objects inside the cupboard will have baselines a bit further up and thus appear behind the door.
Title: Re: Concerning Objects (Walk-to-points and multiple objects)
Post by: AnasAbdin on Thu 05/06/2014 10:31:22
1. If you are trying to make the player walks to the object's coordinates then you could try this:
Code (ags) Select
player.Walk(oKey.X, oKey.Y, eBlock, eWalkableAreas);

2. You don't actually need two objects for the cupboard, you can switch sprites for a single object.
Code (ags) Select
function oCupboard_Interact()
{
       player.Walk(oCupboard.X, oCupboard.Y, eBlock, eWalkableAreas);
       if ( oCupboard.Graphic == ... ) //closed cupboard sprite number...
       {
            oCupboard.Graphic = ...;   // put sprite number of the opened cupboard...
       }
       else
       {
            oCupboard.Graphic = ...;   // put sprite number of the closed cupboard...
       }
}


To make sure the bag is not visible while the cupboard is closed you can assign a baseline to the bag less than the cupboard's baseline.

Code (ags) Select
oBag.Baseline = ...;

I hope that was helpful  :smiley:
Title: Re: Concerning Objects (Walk-to-points and multiple objects)
Post by: Kamileon on Thu 05/06/2014 12:34:48
All is working well, thanks for the scripting help AnasAbdin :grin: