Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: imagazzell on Thu 11/11/2021 19:25:08

Title: [SOLVED] Variating Speech View Animations
Post by: imagazzell on Thu 11/11/2021 19:25:08
Hi folks,

I'd like to figure out (if possible) how to variate characters' speech views so that the player won't see the exact same animation every time they talk.

For example, in a game like CMI, you'll notice that the characters' heads bob and mouths move in a different pattern for each line, even if you repeat the same line of dialogue over and over. This small detail helps to break up the monotony and add pleasing variety to the talking portions of the game.

So how can something like this be achieved in AGS?

I was thinking maybe you could randomize which frame of a long speech view to start with each time a character speaks, but the SpeechView function doesn't have a parameter for the starting frame. I know that the Animate function does, but is that what we'd want to use here?


Getting even more advanced than that, there are also different animations depending on the mood of the dialogue. For instance, the character might be shocked, their eyes wide and arms outstretched, or angry, with a furrowed brow and hands on their hips. And these animations too appear to be varied in their patterns. I'd love to be able to look under the hood and see how they went about doing all of this back then.

But can these things also be done in AGS? I reckon it'll take a significant number of views to animate, but I'm up for it if the results can be as desired.

Thoughts?
Title: Re: Variating Speech View Animations
Post by: Mandle on Fri 12/11/2021 16:11:20
Replacing characters with several different sprites during such speech scenes?
Title: Re: Variating Speech View Animations
Post by: Cassiebsg on Fri 12/11/2021 16:25:57
Yes, but it'll require mode code and sprites.

One way is having several views and randomizing them.
You can also "split" the character in parts (as in a character for each part: head, body, left arm, left hand, etc...) and animate those independently.

The point being, you'll have to set a new speech view (randomized) before talking every single time.
Title: Re: Variating Speech View Animations
Post by: newwaveburritos on Sat 13/11/2021 02:10:08
I sort of do this mostly just by changing speech views a lot. 
Title: Re: Variating Speech View Animations
Post by: imagazzell on Sat 13/11/2021 03:27:32
Yeah, I figured it would come down to having a bunch of different views and changing SpeechView each time, I was just wondering if there was a more clever and efficient way of doing it that I wasn't aware of. Maybe I can throw a function under repeatedly_execute that randomizes the standard speech view automatically, so that I'd only have to write in a manual view change when the character takes on a specific mood, rather than with every single line of dialogue. I'll think on it some more.

Thanks for the feedback, all.
Title: Re: Variating Speech View Animations
Post by: Khris on Sun 14/11/2021 19:12:21
You don't need repeatedly_execute for that, writing in a manual view change is enough. You don't have to state the speech view when you call Character.Say, you can already easily do exactly what you're looking for.
When the character's mood changes, simply change their speech view, and all subsequent dialog lines will use the new view.
Title: Re: Variating Speech View Animations
Post by: imagazzell on Sun 14/11/2021 20:40:35
Hey, Khris. Maybe I'm not following what you're suggesting, but my idea for a function under repeatedly_execute was for randomizing the plain (moodless) speech view between, say, 3-4 different animations, so that each time the character says something, it won't be the same single view every time, without the need to manually write in a view change for every line of speech. The thought was that whenever the character speaks, it will play the currently assigned view animation, which is continuously, automatically randomizing in the background, without me needing to tell it to use a different view each time. Is there a better approach for such a result?
Title: Re: Variating Speech View Animations
Post by: Khris on Mon 15/11/2021 08:21:53
I see, I thought you were talking about changing the view between moods. Not sure how far along the custom .Say command is, but without it you indeed have to use repeatedly_execute exactly like you described it.
Title: Re: Variating Speech View Animations
Post by: imagazzell on Tue 16/11/2021 02:55:59
Yeah, the mood-specific view changes would be in addition to the normal view variations, and in those cases, you are exactly right.
Title: Re: Variating Speech View Animations
Post by: timid_dolphin on Wed 17/11/2021 04:45:34
I've got a bunch of general mood functions in a script file with all of my little character animations.
So all of the logic around changing character views is encapsulated in these, and they can be easily called from anywhere in the script, or within dialogue scripts.

eg:
  paulThinking();
PAUL: Hey, wait a second...
  paulAngry();
PAUL: That guy didn't pay for those bananas!
  paulShakeFist();
  paulSigh();
  paulNeutral();
PAUL: Oh well...
Title: Re: Variating Speech View Animations
Post by: imagazzell on Wed 17/11/2021 06:15:45
Quote from: timid_dolphin on Wed 17/11/2021 04:45:34
I've got a bunch of general mood functions in a script file with all of my little character animations.
So all of the logic around changing character views is encapsulated in these, and they can be easily called from anywhere in the script, or within dialogue scripts.

eg:
  paulThinking();
PAUL: Hey, wait a second...
  paulAngry();
PAUL: That guy didn't pay for those bananas!
  paulShakeFist();
  paulSigh();
  paulNeutral();
PAUL: Oh well...
Yeah, something like that is what I had in mind for the mood views. Did you just put all of the called functions in your global script or did you create a new script for all of them?
Title: Re: Variating Speech View Animations
Post by: timid_dolphin on Fri 19/11/2021 22:35:35
I like to categorise my functions and keep them out of the main script where possible.

So I have a script which has all of my custom character animations, as well as costume changes, so all of the logic around that stuff is wrapped up in neat little functions.

I think it's a good idea to spend a bit of time sorting out these things at the start so when it comes to writing dialogue you can just drop in different gestures and expressions on the fly, it means you can get away with writing less when you can communicate something more directly with 'acting'!

If you can figure out how to do it (I'm not quite there yet!) these functions should be put inside the character object, so instead of paulAngry(); you would call cPaul.angry();
Title: Re: Variating Speech View Animations
Post by: timid_dolphin on Mon 22/11/2021 19:26:23
Ok, so here's how it works:

first you need to go into the character editor and add a custom property to the schema for your alternate views, eg angryView. For each character you can initialise this in the character editor with the view you want to use.

Then in your script file with all of your character animation stuff, add this function:
Code (ags) Select

function angry(this Character*)
{
  this.SpeechView = this.GetProperty("angryView");

}


and in the header for this file:

Code (ags) Select

import function angry(this Character*);


now you can just put cBob.angry(); so switch to the angry speechview. It won't switch back though so you need another function to go back to the default.
This is a lot better for me because previously i had separate functions for every character, which clutters up the autopredict menu. It's also a neater object orientated way of organising the code.
Title: Re: Variating Speech View Animations
Post by: imagazzell on Wed 01/12/2021 05:49:19
Quote from: timid_dolphin on Mon 22/11/2021 19:26:23
Ok, so here's how it works:

first you need to go into the character editor and add a custom property to the schema for your alternate views, eg angryView. For each character you can initialise this in the character editor with the view you want to use.
Hey, timid_dolphin. I like the sound of this approach for the organization and streamlined scripting, but I'm a little unclear on how to set up the custom properties (i.e., what to set as the type and value, etc.). Are you simply setting the type to "number" and the value to the number of the appropriate view?
Title: Re: Variating Speech View Animations
Post by: timid_dolphin on Wed 01/12/2021 09:07:24
Quote from: imagazzell on Wed 01/12/2021 05:49:19
Hey, timid_dolphin. I like the sound of this approach for the organization and streamlined scripting, but I'm a little unclear on how to set up the custom properties (i.e., what to set as the type and value, etc.). Are you simply setting the type to "number" and the value to the number of the appropriate view?

Your instincts are absolutely correct!
Title: Re: Variating Speech View Animations
Post by: imagazzell on Wed 01/12/2021 22:33:51
Great! Thank you. Seems obvious now, looking back at it.

And thanks again for the clever idea. I'll report back if I encounter any roadblocks implementing it.
Title: Re: Variating Speech View Animations
Post by: timid_dolphin on Thu 02/12/2021 10:18:45
Awesome! Glad you liked it - thanks for the motivation to figure out that object structuring stuff in AGS.

I'm learning to code for the first time so it's satisfying to apply some of the concepts I've been learning with webdev stuff in AGS!