I am trying to make left and right movements for mobile, I have made 2 TouchScreenButton
s and a CanvasLayer
for them. Here is my script:
extends Sprite2D
const speed : int = 5
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if Input.is_action_pressed("game_left"):
position.x += Vector2.LEFT * speed * delta
if Input.is_action_pressed("game_right"):
position.x += Vector2.RIGHT * speed * delta
I was trying to make a right and left movement for a 2d mobile game, but I got the Invalid Operants 'float' and 'Vector2' in operator '+' error.