dora/Player.gd

31 lines
668 B
GDScript
Raw Normal View History

2018-07-19 15:36:56 +02:00
extends KinematicBody
2018-07-19 15:36:51 +02:00
2018-07-19 15:36:56 +02:00
var velocity = Vector3()
2018-07-19 15:36:51 +02:00
func _ready():
2018-07-19 15:37:00 +02:00
print("player init")
2018-07-19 15:36:51 +02:00
2018-07-19 15:36:56 +02:00
func _physics_process(delta):
var direction = Vector3()
2018-07-19 15:37:00 +02:00
if Input.is_action_pressed("ui_up"):
2018-07-19 15:37:04 +02:00
direction += Vector3(0, 0, -1)
2018-07-19 15:37:00 +02:00
if Input.is_action_pressed("ui_down"):
2018-07-19 15:37:04 +02:00
direction += 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)
2018-07-19 15:36:56 +02:00
2018-07-19 15:37:00 +02:00
func _process(delta):
# Called every frame. Delta is time since last frame.
# Update game logic here.
pass