Author Topic: Character interactions with objects/hotspots.  (Read 108 times)

Character interactions with objects/hotspots.
« on: 07 Dec 2017, 04:14 »
I'm using the default AGS template with VIEW 1 and VIEW 2 default views for walking and talking. Right now I'm trying to get my character to click an object (video game controller) and that would make my character sit down in front of the TV and start playing video games. My first instinct is to create a loop of him shifting while sitting in a new view(3), creating a hotspot over the controller and having the any click option call out to
Code: Adventure Game Studio
  1. character.ChangeView(3);

I tried this and nothing happened. Is there a simple way to get the character to interact with a hotspot that took him out of the walk cycle and into an animation of him sitting? Thanks.

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Character interactions with objects/hotspots.
« Reply #1 on: 07 Dec 2017, 07:58 »
I think there's a bit more to it than that, but first of all: is your character name "character"? (I doubt it, because I think it's a reserved name in AGS.) When you have a function like Character.ChangeView(), you have to replace "Character" with the name of your character (or some other pointer, like player). For example, cGuybrush.ChangeView(3); or player.ChangeView(3);

Also, you know how you can give the each view a name? You can use those names instead of just the view number in the code, which makes it easier to follow when you read. Compare:

Code: Adventure Game Studio
  1. character.ChangeView(3);

and

Code: Adventure Game Studio
  1. cBob.ChangeView(BOB_VIDEOGAMING);

Reading the first version, you can't tell what's going on. In the second version, it's self-explanatory.

Khris

    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
  • Khris worked on a game that was nominated for an AGS Award!
Re: Character interactions with objects/hotspots.
« Reply #2 on: 07 Dec 2017, 10:11 »
There are two separate issues here. The first is to get AGS to do anything at all when you click the controller. To make sure this is happening, the function that contains your code has to be linked to the hotspot event. How to do this is explained in the manual's tutorial: http://www.adventuregamestudio.co.uk/manual/acintro3.htm (bottom half)

Just put a Display("It works"); inside the function for now. Also, I'd probably use the "interact with hotspot" event, not "any click on hotspot". How is your game's interface set up? Are you using the BASS template? Or the Default one?

Once that works, you can focus on the script commands; you'll want to not just set the character's view but also .Animate() them. In this case, LockView() is a better choice. Again, this is explained in the manual, in the "Character" section, on the page for "Animate" (i.e. easy to find once you have a basic grasp of the manual's structure).


Finally. When you are about to open a topic here, take a few seconds to think about how likely it is that somebody else has already had the exact same problem. Chances are, there's at least one existing thread about any common beginner's issue. Try to find that first, before hitting that "New Topic" button.