Multiple speaking animations in one pose?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
bob-artist
Newbie
Posts: 5
Joined: Thu Apr 15, 2021 8:23 pm
Tumblr: bob-artist
Contact:

Multiple speaking animations in one pose?

#1 Post by bob-artist » Sun Apr 25, 2021 8:58 pm

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!

User avatar
Syrale
Regular
Posts: 99
Joined: Sun Oct 25, 2015 10:28 am
Completed: Robot Daycare, Deep Sea Valentine, Locke(d)
Projects: Artificial Selection, rei_carnation
itch: kigyo
Discord: kigyo#2564
Contact:

Re: Multiple speaking animations in one pose?

#2 Post by Syrale » Tue Apr 27, 2021 5:36 am

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")

User avatar
bob-artist
Newbie
Posts: 5
Joined: Thu Apr 15, 2021 8:23 pm
Tumblr: bob-artist
Contact:

Re: Multiple speaking animations in one pose?

#3 Post by bob-artist » Tue Apr 27, 2021 1:59 pm

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!

User avatar
bob-artist
Newbie
Posts: 5
Joined: Thu Apr 15, 2021 8:23 pm
Tumblr: bob-artist
Contact:

Re: Multiple speaking animations in one pose?

#4 Post by bob-artist » Tue Apr 27, 2021 3:10 pm

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!

User avatar
Syrale
Regular
Posts: 99
Joined: Sun Oct 25, 2015 10:28 am
Completed: Robot Daycare, Deep Sea Valentine, Locke(d)
Projects: Artificial Selection, rei_carnation
itch: kigyo
Discord: kigyo#2564
Contact:

Re: Multiple speaking animations in one pose?

#5 Post by Syrale » Wed Apr 28, 2021 4:12 am

I'm glad it worked out. No Problem!

Post Reply

Who is online

Users browsing this forum: Ocelot, RodFireProductions