Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Fri 19/11/2010 19:26:09

Title: character walks to an object from a gui button
Post by: barefoot on Fri 19/11/2010 19:26:09
Hi

I was wondering if its possible to have main character walk to an object from a gui button click?

EG
When you click 'Walk to Bridge' gui button for example the character walks to the bridge (object)..

Can AGS determine xy for an object and have the char go there?

I have done a search but to no avail...

cheers

barefoot




Title: Re: character walks to an object from a gui button
Post by: Matti on Fri 19/11/2010 19:40:04
Quote from: barefoot on Fri 19/11/2010 19:26:09
Can AGS determine xy for an object and have the char go there?

Um, yes.

cEgo.Walk(oObject.X, oObject.Y);

If you had typed "object" in the index search box of the manual, you would've immediately found your answer. Also, there is nothing whose coordinates can't be get. If AGS couldn't handle such simple stuff, I'd switch the engine.
Title: Re: character walks to an object from a gui button
Post by: barefoot on Fri 19/11/2010 19:58:09
Yes, I know about object x y Matti.. 

but i have found various way of going about what im looking for.. but thanks anyway..

barefoot
Title: Re: character walks to an object from a gui button
Post by: monkey0506 on Sat 20/11/2010 04:30:03
To be totally sure that you understand Matti's response, you can call that command from within the GUI Button's OnClick event handler:

function btnWalk_OnClick(GUIControl *control, MouseButton button)
{
  if (player.Room == 4)
  {
    player.Walk(object[3].X, object[3].Y);
  }
}
Title: Re: character walks to an object from a gui button
Post by: barefoot on Sat 20/11/2010 10:45:58
Cheers Monkey, ive noted that.

barefoot
Title: Re: character walks to an object from a gui button
Post by: monkey0506 on Sat 20/11/2010 14:37:14
Okay, well I'm glad you got it sorted out. Just the way it came across (to me) was that Matti gave you an answer and you just immediately shot him down saying you know a better way. Ah well.