how to make child (buttons) not rotate or move with Player

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

i want to make touch screen for my game but when i add it as a child to my player
it just rotates with my player i want to make it not follow parent movements
in the player script i made its rotation_degrees changes so that it can aim
![enter image description here][1]

Why are you adding the buttons as a child to the player? Wouldn’t it be better to have the buttons separate from the character (they won’t rotate with the character then). Also, your image is broken.

exuin | 2020-09-21 01:42

:bust_in_silhouette: Reply From: njamster

By default child nodes move along with their parents. If you don’t want this to happen for your buttons, that’s a clear sign that they shouldn’t be children of the player!
Your scene should probably should look somewhat like this:

- Root
  - CanvasLayer
    - Button1
    - Button2
    - ...
  - Player
  - ...

UI-elements usually are supposed to stay in fixed positions, which is why it’s a good idea grouping them under a CanvasLayer-node independent from the player.

That being said, if the buttons (for whatever reason) have to be children of the player, you can make their transformation independent from the parent by doing this:

$Button1.set_as_toplevel(true)
$Button2.set_as_toplevel(true)