Topic was automatically imported from the old Question2Answer platform.
Asked By
Alone Developer
So guys, i just finished a “Your first game” from godot tutorials,and i exported that game to Android,so bassicaly game works on android fine,but problem with game “Dodge The Creeps” is that i just can’t move my character cause i guess it’s script isn’t designed for that,on pc it works well with arrow keys,but what about Android what should i do and can i find somewhere more about it?
extends Node2D
var direction = Vector2(0.0, 0.0)
var speed = 100
onready var player = $character
func _input(event):
if event is InputEventScreenTouch:
if event.is_pressed():
direction = player.to_local(event.position).normalized()
else:
direction = Vector2(0.0, 0.0)
elif event is InputEventScreenDrag:
direction = player.to_local(event.position).normalized()
func _process(delta):
position = position + direction * speed * delta
you just need to map the direction to left/right/up/down, or add button to control direction;