Move Player on all 4 directions
This commit is contained in:
parent
8a4eca488f
commit
4655cf14df
17
Player.gd
17
Player.gd
|
@ -9,11 +9,20 @@ func _physics_process(delta):
|
||||||
var direction = Vector3()
|
var direction = Vector3()
|
||||||
|
|
||||||
if Input.is_action_pressed("ui_up"):
|
if Input.is_action_pressed("ui_up"):
|
||||||
print("Onward!")
|
direction += Vector3(0, 0, -1)
|
||||||
self.translate(Vector3(0, 0, 1))
|
|
||||||
if Input.is_action_pressed("ui_down"):
|
if Input.is_action_pressed("ui_down"):
|
||||||
print("not so onward...")
|
direction += Vector3(0, 0, 1)
|
||||||
self.translate(Vector3(0, 0, -1))
|
if Input.is_action_pressed("ui_left"):
|
||||||
|
direction += Vector3(-1, 0, 0)
|
||||||
|
if Input.is_action_pressed("ui_right"):
|
||||||
|
direction += Vector3(1, 0, 0)
|
||||||
|
|
||||||
|
direction.y = 0
|
||||||
|
direction = direction.normalized()
|
||||||
|
|
||||||
|
var speed = 0.2
|
||||||
|
direction *= speed
|
||||||
|
self.translate(direction)
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
# Called every frame. Delta is time since last frame.
|
# Called every frame. Delta is time since last frame.
|
||||||
|
|
Loading…
Reference in a new issue