![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Facu1245 |
I have a sprite that has to have a little delay when its parent node rotates, the problem is that I don’t know how to do this, to set the sprite to stay the same and then rotate smoothly until it is the same as the parent
Hmm tricky one… Seeing how the sprite is a child of the parent I think when the parent is rotated the child is rotated along side of it via the engine code. This code would do it if the sprite wasn’t a child:
var rotation_speed = 15.0
var my_sprite = get_node("Sprite")
func _physics_process(delta):
# replace RIGHT with whatever direction your sprite normally faces
var target_rotation= Vector2.RIGHT.rotated(global_rotation)
var current_direction = Vector2.RIGHT.rotated(my_sprite.global_rotation)
my_sprite.global_rotation = current_direction.linear_interpolate(target_direction, rotation_speed * delta).angle()
timothybrentwood | 2021-05-11 02:23
I don’t know if it will be a good solution because how I have it is:
Every time the player moves the mouse, the character points to where the camera is, then in a Ysort node (which is where the sprite I want with relay is) in the _process function of Ysort I check if they do not have the same angle, yes It is different that I gently fix it
Facu1245 | 2021-05-11 02:46