summaryrefslogtreecommitdiffstats
path: root/assets/weapons
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2022-07-22 03:41:41 -0400
committerMalfurious <m@lfurio.us>2022-07-22 03:41:41 -0400
commit1f534358c264560662793ff72bfcc57d3d155b5b (patch)
tree31454d68d393d7e14898cb34f04541900857ffcd /assets/weapons
parent3e8167c43cc312a814f6e899d08c18b7155d710a (diff)
downloadproject-s-1f534358c264560662793ff72bfcc57d3d155b5b.tar.gz
project-s-1f534358c264560662793ff72bfcc57d3d155b5b.zip
Implement Goo Gun primary fire
Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to '')
-rw-r--r--assets/weapons/goo_gun/GooGun.gd29
-rw-r--r--assets/weapons/goo_gun/GooGun.tscn4
2 files changed, 32 insertions, 1 deletions
diff --git a/assets/weapons/goo_gun/GooGun.gd b/assets/weapons/goo_gun/GooGun.gd
new file mode 100644
index 0000000..4839f09
--- /dev/null
+++ b/assets/weapons/goo_gun/GooGun.gd
@@ -0,0 +1,29 @@
+extends Spatial
+
+export var is_firing = false
+export var fire_rate = 0.1
+export var projectile_spread = 0 #TODO
+export var projectile_scalar = 25
+export var look_angle = 0
+export var weapon_pitch = 0
+
+var time_since_fire = 0
+
+var Bullet = preload("res://assets/weapons/goo_gun/Bullet.tscn")
+
+func _physics_process(delta):
+ if is_firing:
+ time_since_fire += delta
+ if time_since_fire >= fire_rate:
+ time_since_fire -= fire_rate
+ do_fire_projectile()
+ else:
+ time_since_fire = fire_rate
+
+func do_fire_projectile():
+ var bullet = Bullet.instance()
+ $Nozzle.add_child(bullet)
+ bullet.set_as_toplevel(true)
+ var shoot_direction = Vector3.FORWARD.rotated(Vector3.LEFT, weapon_pitch)
+ shoot_direction = shoot_direction.rotated(Vector3.UP, look_angle)
+ bullet.apply_central_impulse(shoot_direction.normalized() * projectile_scalar)
diff --git a/assets/weapons/goo_gun/GooGun.tscn b/assets/weapons/goo_gun/GooGun.tscn
index f0b9622..edf2901 100644
--- a/assets/weapons/goo_gun/GooGun.tscn
+++ b/assets/weapons/goo_gun/GooGun.tscn
@@ -1,7 +1,8 @@
-[gd_scene load_steps=7 format=2]
+[gd_scene load_steps=8 format=2]
[ext_resource path="res://assets/weapons/goo_gun/gun_material.tres" type="Material" id=1]
[ext_resource path="res://assets/weapons/goo_gun/tank_material.tres" type="Material" id=2]
+[ext_resource path="res://assets/weapons/goo_gun/GooGun.gd" type="Script" id=3]
[sub_resource type="CubeMesh" id=1]
material = ExtResource( 1 )
@@ -23,6 +24,7 @@ bottom_radius = 0.088
height = 0.429
[node name="GooGun" type="Spatial"]
+script = ExtResource( 3 )
[node name="Body" type="MeshInstance" parent="."]
mesh = SubResource( 1 )