From 4c0bd4f0ab32a2489130d04b08c39d008c8c9961 Mon Sep 17 00:00:00 2001 From: LeightonGinty Date: Sat, 29 Oct 2022 16:37:26 +0100 Subject: can shoot now --- KinematicBody2D.gd | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'KinematicBody2D.gd') diff --git a/KinematicBody2D.gd b/KinematicBody2D.gd index dad1eb5..a1a3770 100644 --- a/KinematicBody2D.gd +++ b/KinematicBody2D.gd @@ -1,7 +1,7 @@ extends KinematicBody2D export (int) var speed = 200 - +var spawn_object = load("res://Bullet.tscn") var velocity = Vector2() func get_input(): @@ -17,5 +17,14 @@ func get_input(): velocity = velocity.normalized() * speed func _physics_process(delta): + + + get_input() velocity = move_and_slide(velocity) + if Input.is_action_just_pressed("click"): + var obj = spawn_object.instance() + obj.position = get_position() + obj.position.x -= 500 + obj.position.y -= 250 + add_child(obj) -- cgit v1.2.3-70-g09d2