I am messing around with making a mobile game, which means touch controls. I have stages set up as individual scenes, and each scene has a Player node with touch controls attached. My problem is that, when I transition scenes to change levels, the game stops registering the screen touch event. Here is the relevant code:
if Input.is_action_pressed("ui_left") || $"TControls/Left".is_pressed():
velocity.x = -SPEED
elif Input.is_action_pressed("ui_right") || $"TControls/Right".is_pressed():
velocity.x = SPEED
velocity.y += GRAVITY
velocity = move_and_slide(velocity, FLOOR)
That's in the Player object. I've obviously removed some unrelated code, but this is essentially how I'm dealing with the touch controls. What I think is happening is that, when I load a new scene, it creates a new Player object, which in turn creates new touch controls which don't get registered as pressed until the player re-touches the button.
It's not a major issue, but, it would help the flow of the gameplay a lot if the movement persisted. Does anyone have any ideas on how to get around this issue? Thanks a bunch in advance.