X-Git-Url: http://git.purplebirdman.com/star-foxy.git/blobdiff_plain/30cc1662f898e7b25cfe989eb74cdaa5576ec4c2..c25901f552013905d08827f2ff004244a57f8d4f:/player/player.gd diff --git a/player/player.gd b/player/player.gd index fa2445f..2b608dc 100644 --- a/player/player.gd +++ b/player/player.gd @@ -6,6 +6,7 @@ const SPEED_TURN = 120 const SPEED_AIM = PI / 2 var velocity = Vector3() +var scene_bullet = preload("res://player/bullet.tscn") # Called when the node enters the scene tree for the first time. func _ready(): @@ -36,6 +37,17 @@ func get_player_input(delta): elif Input.is_action_pressed("player_aim_right"): rotate(Vector3.UP, -SPEED_AIM * delta) + # offense + if Input.is_action_pressed("player_fire"): + print("firing!") + fire_bullet() + +func fire_bullet(): + var bullet = scene_bullet.instance() + $"..".add_child(bullet) + bullet.translation = translation - transform.basis.x * 2 + bullet.rotation = rotation + bullet.direction = -transform.basis.z func _process(delta): # get velocity changes player asks for