How can I use scale on a scene with an AnimationPlayer?

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

I was first flipping my sprite with $Sprite.flip_h, which worked fine with the animations, but I want to add more sprites to this scene, and don’t want to have to flip each one.

So I replace that with self.scale.x = -1, and my scene (character) seems to flip back and forth really fast, it looks like it’s flickering. Seems like every frame it’s switching back and forth.


(this isn’t totally accurate, it’s much faster).

I’m guessing that the animation is setting the self.scale.x property each frame as well, which is causing the problem, but I can’t figure out where or how.

This is my scene layout:
enter image description here

and the function:

func move(delta):
var input = ZERO
input.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
input.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
input = input.normalized()

self.scale.x = -1

if input != ZERO:
	anim.play("Run")
	
	#if input.x < 0:
		#self.scale.x = -1
	#else:
		#self.scale.x = -1
		
	velocity = velocity.move_toward(input * SPEED, ACCEL * delta)
else:
	anim.play("Idle")
	velocity = velocity.move_toward(ZERO, FRICT * delta)
	
velocity = move_and_slide(velocity)
:bust_in_silhouette: Reply From: njamster

That’s a known issue. Also check out my comment over here.

thanks,self.scale.x = self.scale.y * 1 worked

stackers | 2020-04-02 23:40