How to prevent multiple apply_scale

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

I have some code who rotates parts of the character based on the mouse position:

look_at(get_global_mouse_position())

if rotation_degrees > 80 or head.rotation_degrees < -80
		apply_scale(Vector2(-1, 1))

But when it reaches this condition, it applies the scale multiple times until the condition becomes false, its a “loop” similar to what happens with the animations, but with animations we can check what is the current animation with get_current_animation()

I know I could just check the current scale to see which position he’s pointing, but by change it directly it don’t work the same as apply_scale.

are you trying to get a sprite to face the mouse position? if so you can get the value “rotation_degrees” from a node and change this value directly. also note there is a function that can give you a new rotated vector using Vector2.rotated(float phi)

happycamper | 2018-07-13 15:25

Sorry for the delay, i was very occupied those days.

Yeah, I’m trying to get some sprites do face the mouse position, really thanks for the tip, it worked! :slight_smile:

Aryn | 2018-07-24 17:10