Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Gepard on Fri 02/03/2007 16:07:55

Title: Object visible at...
Post by: Gepard on Fri 02/03/2007 16:07:55
I wantÃ,  to make an operation. I have a character (C) and an object (O) which is not initially visible. Now the character is WALKING. I want to do this: If I use inventory on C, the C will STOP (for example: x100, y251) and there will be a short animation and after that animation I want the object to be visible again, but on the same place where the character STOPPED. Can I do that?

Thanks in advance.
Title: Re: Object visible at...
Post by: Ashen on Fri 02/03/2007 16:32:59
Have you tried? That's all pretty simple coding - you just need to stop the character moving (http://www.adventuregamestudio.co.uk/manual/Character.StopMoving.htm) and set the Object's postion (http://www.adventuregamestudio.co.uk/manual/Object.SetPosition.htm) to match character[C].x/y before you turn it on:

cC.StopMoving(); // Or whatever C's actual script-o-name is
object[0].SetPosition(cC.x, cC.y);
obejct[0].Visible = true;


Other things to consider:
- You might need an offset in the X value. Objects coords are taken from the bottom left corner, while characetr coords are the centre of the sprite. You may need to make it cC.x - (half object width) to make it look right.
- Since the Character Interactions are in the Global Script, you'll probably need to add a check that the player is in the right room when they use the item. (If this can only happen in one room - e.g. C doesn't change rooms - don't worry about this.) Also, remember that you can't you the Object's Script-o-name (oDoor, etc) in Global Script.

Please, make an effort to solve things yourself before posting - you could've figured this one out by just reading the manual. Even if it doesn't work, you can tell us what you tried and what the problems where.
Title: Re: Object visible at...
Post by: Gepard on Fri 02/03/2007 17:18:08
I tried, but sorry anyway, never do that again, promise.
Title: Re: Object visible at...
Post by: Ashen on Fri 02/03/2007 17:44:28
What did you try? If you post that, and what went wrong with it, maybe someone can sort out why it didn't work so you'll know for next time. (And, if you post failed attempts it'll stop me accusing you of not trying :))

Have you got it working as you want now?
Title: Re: Object visible at...
Post by: Gepard on Fri 02/03/2007 17:48:19
Yes! Perfect! You will have a special place in my scrolling titles :)