Page 1 of 1

Multiple speaking animations in one pose?

Posted: Sun Apr 25, 2021 8:58 pm
by bob-artist
I'm trying to figure out a way to switch between different speaking animations within a single layered image - for example, one for regular talking, one for yelling, one for if the head is at a 3/4 view, etc. - which then play in sync with the dialogue. So far, the only method I could figure out is to duplicate the entire layered image and define it as a new pose with a different animation assigned to its speaking attribute. It works, but it hardly seems efficient. Is it possible to have multiple speaking animations within a single pose that can be chosen in the script and then run in sync with the dialogue display?

This is a snippet of my layered image setup, which is basic since I'm just testing things out. I'm still trying to wrap my head around how variants work.

Code: Select all

layeredimage merritt:

    always "merritt_base"

    group eyes auto:
        attribute blinking default:
            "merritt_blinking"

    group mouth auto:
        attribute neutral default

        attribute speaking:
            "merritt_talking"
My current speaking animation:

Code: Select all

image merritt_talking:

    "merritt_mouth_opentalk"
    .25
    "merritt_mouth_pursed"
    .25
    "merritt_mouth_opentalk"
    .25
    "merritt_mouth_neutral"
    .25
    repeat
And then, because I really wanted the lip flap to stop when the dialogue finishes displaying, I'm using this callback I found via some heavy googling. (When I tried the config speaking attribute instead, I couldn't get the lip flap to stop until I clicked to narration or a different character.)

Code: Select all

init python:
    def shutup_merritt(event, interact=True, **kwargs):
        if event == "slow_done" or event=="end":
            renpy.show("merritt neutral")
            renpy.restart_interaction() # this
        elif event == "begin":
            renpy.show("merritt speaking")

define m = Character("Merritt", image="merritt", callback=shutup_merritt)
This was the only way I could find to stop the lip flap, but then it bakes in the neutral-mouth expression, and I'm not sure if there's a better way to go about this.

Does anyone have any suggestions? I'm brand new to this, so any help is greatly appreciated!

Re: Multiple speaking animations in one pose?

Posted: Tue Apr 27, 2021 5:36 am
by Syrale
Maybe there's a more elegant solution, but you could try working with renpy.get_attributes().

I didn't really test this, but I hope it works (or at least helps you find something that does):

Code: Select all

init python:
    def shutup_merritt(event, interact=True, **kwargs):
        if event == "slow_done" or event=="end":
    		if "neutral" in renpy.get_attributes("merritt"):
    			renpy.show("merritt neutral")
    		elif "angry" in renpy.get_attributes("merritt"):
    			renpy.show("merrit angry")
    		renpy.restart_interaction()
        elif event == "begin":
    		if "neutral" in renpy.get_attributes("merritt"):
    			renpy.show("merritt speaking")
    		elif "angry" in renpy.get_attributes("merritt"):
            		renpy.show("merritt yelling")

Re: Multiple speaking animations in one pose?

Posted: Tue Apr 27, 2021 1:59 pm
by bob-artist
Ah, thanks for the tip, I really appreciate it. I tried it out and it switched the mouth perfectly. The only problem is now, for some reason, the speaking mouth no longer stops moving at the end of the dialogue. I assume there's something off with restart_interaction, since that's what seemed to stop the lip flap. No luck tweaking it so far, but if I can get it to work, I'll post an update. Thanks again!

Re: Multiple speaking animations in one pose?

Posted: Tue Apr 27, 2021 3:10 pm
by bob-artist
Update: I got it to work somehow! It's entirely possible my code is still technically wrong in ways I don't understand, but for the time being it's doing what I want.

New layered image setup:

Code: Select all

layeredimage merritt:

    always "merritt_base"

    group eyes auto:
        attribute blinking default:
            "merritt_blinking"

    group exp auto:
        #this is the static unmoving mouth, since hiding the speaking mouth leaves an empty void

        attribute neutral default

    group mouth auto:
        #this is the speaking mouth

        attribute speaking:
            "merritt_talking"

        attribute yelling:
            "merritt_yelling"
And the callback:

Code: Select all

init python:
    def shutup_merritt(event, interact=True, **kwargs):
        if event == "slow_done" or event=="end":
            renpy.show("merritt -speaking")
            renpy.show("merritt -yelling")
            renpy.restart_interaction()
        elif event == "begin" and "neutral" in renpy.get_attributes("merritt"):
            renpy.show("merritt speaking")
        elif event == "begin" and "shocked" in renpy.get_attributes("merritt"):
            renpy.show("merritt yelling")
Thanks again for cluing me in to get.attributes!

Re: Multiple speaking animations in one pose?

Posted: Wed Apr 28, 2021 4:12 am
by Syrale
I'm glad it worked out. No Problem!