How do I achieve the Paper mario effect in the attached video?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nen

Hey guys I got a question, is there a way to replicate this in a controlled manner?
Basically thanks to some help from YeOldeDM last night, I got a better version of my movement controls working but then I noticed this cool effect with the only downside being sometimes the sprite doesn’t appear at all. I can remove that effect but was wondering if there is any way to keep the change in scale such that turning produces this effect

Code that produces the effect but has the sprite vanishing issue Credit YeOldeDM

if input_direction != Vector2.ZERO:
    $AnimatedSprite.play("Walk")
    if input_direction.x != 0:
        $AnimatedSprite.scale.x = input_direction.x
else:
    $AnimatedSprite.play("Idle")

Code that removes the vanishing effect but doesn't keep the cool turning effect

if input_direction != Vector2.ZERO:
    $AnimatedSprite.play("Walk")
    if input_direction.x > 0:
        $AnimatedSprite.scale.x = 1
    elif input_direction.x < 0:
        $AnimatedSprite.scale.x = -1
else:
    $AnimatedSprite.play("Idle")

https://i.webcomicshub.co.uk/VBOeexvvpW.mp4

:bust_in_silhouette: Reply From: jtarallo

Hi. I’d try and up the min value for which the transformation occurs. For example in the code by YeOldeDM:

if input_direction != Vector2.ZERO:
    $AnimatedSprite.play("Walk")
    if abs(input_direction.x) >= 0.10:
        $AnimatedSprite.scale.x = input_direction.x 
else:
    $AnimatedSprite.play("Idle")

I’d try and play with the 0.10 value and see to what min value you can lower it without it producing the undesired effect,

Hope it helps

I’ll try it and see what happens although I was wondering if I could create a method or something that slowly changed the scale.x value over a set amount of time. if anything comes to mind regarding this please do tell

Nen | 2020-06-07 20:05

Edited the code snippet, had a wrong indentation on the “else” block

jtarallo | 2020-06-07 20:07

You could create a variable and set it when input_direction changes and add a setter function to it to handle this “slow change”. In the setter function you could check for a variation in prev scale value > X or maybe a change of direction and apply an interpolation for the transformation if you need to. Otherwise just set the value straight. I don’t know if it would be a bit prone to produce weird results…

jtarallo | 2020-06-07 20:19