How to make touch screen controls stay in place
Asked Answered
S

5

0

Well I would like to explain properly but as English is not my first language please try to understand what I say, so I am trying to learn godot and game development in general but as I'm new to this I'm facing many issues every now and then so for now I wanted to make my touch screen control stay on the screen on the same place,which was working fine until I added camera2d node to my player which started following my player(which is good) but my controls are moving with it, please help me with this. -thamks

Shonda answered 22/12, 2023 at 11:56 Comment(0)
S
0

Make your touch screen control node a child of player. (i.e. attached to the same parent as your Camera2D).

Swords answered 22/12, 2023 at 15:9 Comment(0)
R
0

You could probably use a CanvasLayerNode and put your touch screen controls as children of that canvaslayernode

Rufus answered 22/12, 2023 at 18:57 Comment(0)
S
0

Rufus

Here is how I have set the controls and player

Shonda answered 23/12, 2023 at 7:11 Comment(0)
S
0

Swords

Hey thanks 'hay' your method fixed my problem thanks alot but I want to ask a question, will this approach be good enough for making my game, I mean in further making progress in my game I won't need to change it right?

Shonda answered 23/12, 2023 at 7:23 Comment(0)
S
1

Shonda As long as you want the camera to always stay centered on the player, this will work. If you ever need the camera to be somewhere else, you would need to do something more complicated to manage the camera. e.g. some side-scroller games will have the camera lag behind the player by a second or so.

It might be better to make the UI touch controls a child of the camera, rather than the player. Then the ui will stay in sync with the camera, even if you move the camera off the player.

Swords answered 23/12, 2023 at 15:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.