0 votes

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.

asked Jul 11 in Engine by Aryn (48 points)
edited Jul 11 by Aryn

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)

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! :)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.