Character Moving Forward while Talking

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
GoingGoingKeith
Newbie
Posts: 13
Joined: Sat Dec 26, 2020 7:58 pm
itch: goingoingkeith
Contact:

Character Moving Forward while Talking

#1 Post by GoingGoingKeith » Sun Feb 07, 2021 8:51 pm

Hi everyone! I'm trying to do something similar to DokiDoki Literature where the character moves forward as they talk. I know it has something to do with character callbacks, but I've never worked with them before. There is a thread out there with some code, I tested it but it dosen't seem to be working. Any inisight into this solution would be appreciated. Thanks! Aviewtopic.php?t=50142

User avatar
Angelo Seraphim
Regular
Posts: 32
Joined: Tue May 21, 2019 8:00 am
Completed: Enamored Risks (NaNoReNo 2020)
Projects: 616 Charagma
Organization: GLSUoA
Deviantart: glsuoa
itch: glsuoa
Location: London, UK
Discord: Just A Concept#9599
Contact:

Re: Character Moving Forward while Talking

#2 Post by Angelo Seraphim » Mon Feb 08, 2021 8:51 am

Hi @GoingGoingKeith,

Here's what I use in my game:

Code: Select all

init python:
    def stacey_callback(event, interact=True, **kwargs):
        if not interact:
            return
	
	## Voice bleeps
        if event == "show_done":
            renpy.sound.play("audio/voice/stacey_bip.wav",
                             channel='voice_bleeps', fadein=0.1)
        elif event == "slow_done":
            renpy.sound.stop(channel='voice_bleeps', fadeout=0.1)
	
	## If the character is currently shown on screen, this will search for the character 'tag'
        if renpy.showing("anastasia"):
        
            if event == 'begin': ## When the character is speaking.
                renpy.show("anastasia", zorder=10, at_list=[speaking])
                
            elif event == 'end': ## When the character is not the current speaking character.
                renpy.show("anastasia", zorder=0, at_list=[not_speaking])
                
define an = Character('Stacey', image="anastasia", callback=stacey_callback)
The transform:

Code: Select all

transform speaking:
    subpixel True transform_anchor True yanchor 0.0
    ease 0.15 yoffset 30 zoom 1.0

    on hide:
        alpha 1.0
        linear 0.5 alpha 0.0

transform not_speaking:
    subpixel True transform_anchor True yanchor 0.0
    ease 0.15 yoffset 30 zoom 0.85

    on hide:
        alpha 1.0
        linear 0.5 alpha 0.0
Note: The transform may not work correctly for you, however, it should zoom the character in when speaking and out when they're currently not the speaking character.
Image

GoingGoingKeith
Newbie
Posts: 13
Joined: Sat Dec 26, 2020 7:58 pm
itch: goingoingkeith
Contact:

Re: Character Moving Forward while Talking

#3 Post by GoingGoingKeith » Mon Feb 08, 2021 10:38 pm

Thank you! That worked nicely! I needed to put the character definition after the function though. My code ended up looking like this:

Code: Select all

transform speaking:
    linear 0.2 zoom 1.05
transform not_speaking:
    linear 0.2 zoom 1.0
init python:
    def stacey_callback(event, interact=True, **kwargs): ##Can change the function name later on.
        if not interact: 
            return
            ## If the character is currently shown on screen, this will search for the character 'tag'
        if renpy.showing("daisuke"):
        
            if event == 'begin': 
                renpy.show("daisuke", zorder=10, at_list=[speaking])
                
            elif event == 'end': 
                renpy.show("daisuke", zorder=0, at_list=[not_speaking])
define d = Character("Daisuke", image = "daisuke", callback=stacey_callback)

Post Reply

Who is online

Users browsing this forum: Google [Bot], RodFireProductions