Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Gribbler on Fri 01/09/2006 19:15:58

Title: Walking to object before picking it up?
Post by: Gribbler on Fri 01/09/2006 19:15:58
Hi

I have a problem. When I put object in a room and get the player to pick it up object is removed from room no matter where the character is standing. I want him to first go to the object and THEN pick it up (maybe add bending animation too). So here's the question: how can I do it?
I tried various scripts. None worked.

thanks in advance for any help
Title: Re: Walking to object before picking it up?
Post by: Candle on Fri 01/09/2006 19:22:57
See below.
Title: Re: Walking to object before picking it up?
Post by: Gribbler on Fri 01/09/2006 19:32:08
I'm not exactly sure what you mean. Should I use hotspot for that? I know there is 'walk point' but its for hotspots not for objects.
Title: Re: Walking to object before picking it up?
Post by: Candle on Fri 01/09/2006 19:39:21
Sorry about that.
Let me see if I can find it.
Title: Re: Walking to object before picking it up?
Post by: Candle on Fri 01/09/2006 19:47:08
Found this
(http://xs205.xs.to/xs205/06355/movechar.jpg)
Title: Re: Walking to object before picking it up?
Post by: Gribbler on Fri 01/09/2006 20:00:36
thanks. that worked just fine:)
Title: Re: Walking to object before picking it up?
Post by: Khris on Fri 01/09/2006 20:00:58
Aside from this question having been asked here about a million times already, there are various ways.
If you want to simply code it every time, use something like this:
player.Walk(x, y, eBlock);
player.LockView(VIEW); // change this to the pick up-view
player.Animate(...); // play pick up-animation, make sure it's blocking
oItem.Visible=false; // turn off object
player.AddInventory(iItem);
player.UnlockView();
Alternatively, you could use a custom function:
function WalkPickUp(int x, int y, int dir, int obj, InventoryItem*inv) {
Ã,  player.Walk(x, y, eBlock);
Ã,  player.LockView(VIEW); // change this to the pick up-view
Ã,  player.Animate(...dir...); // play pick up-animation, make sure it's blocking
Ã,  object[obj].Visible=false; // turn off object
Ã,  player.AddInventory(inv);
Ã,  player.UnlockView();
}
You could use Custom Properties to store the walk-to coords for objects.
Ã,  player.Walk(object[obj].GetProperty("x"), object[obj].GetProperty("y"), eBlock);