Ways to lock a rotation?

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

I have a Node2D it rotates constantly. Now I have a child object, with an offset, so it rotates around the player. But I want this child object to face always upwards, while rotating around the player.

Edit: Nevermind below, this solution magically stopped to work.
I actually have a solution… but it seems rather silly to use it. I’m sure there are better option than this:

the Node2D:

extends Node2D

var rot = 5.0

func _process(delta):
    rotate(rot * delta)

Child Object: (counteract the rotation)

extends MeshInstance2D

func _process(delta):
	var rot = get_parent().rot
	rotate(-rot * delta)

the only thing I can think of is

func _process(_delta):
    rotation = -get_parent().rotation


func _process(_delta):
    global_rotation = 0.0

so yeah pretty much what you did

OgGhostJelly | 2023-05-16 04:48

1 Like