extends KinematicBody export (PackedScene) var PlayerBullet const SPEED = 32 var velocity = Vector3() func _ready(): pass # Replace with function body. #func _process(delta): # pass func _physics_process(delta): # move velocity = Vector3() if Input.is_action_pressed("ui_right"): velocity.x = 1 elif Input.is_action_pressed("ui_left"): velocity.x = -1 if Input.is_action_pressed("ui_down"): velocity.z = 1 elif Input.is_action_pressed("ui_up"): velocity.z = -1 # Do not multiply by delta when using move_and_slide() velocity = velocity.normalized() * SPEED move_and_slide(velocity) func _on_ShotTimer_timeout(): var bullet = PlayerBullet.instance() bullet.translation = Vector3(translation.x, translation.y, translation.z - 1.0) get_tree().root.get_node("Main/PlayerBullets").add_child(bullet)