diff options
author | Malfurious <m@lfurio.us> | 2022-07-22 03:41:41 -0400 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2022-07-22 03:41:41 -0400 |
commit | 1f534358c264560662793ff72bfcc57d3d155b5b (patch) | |
tree | 31454d68d393d7e14898cb34f04541900857ffcd /assets/characters/base_character | |
parent | 3e8167c43cc312a814f6e899d08c18b7155d710a (diff) | |
download | project-s-1f534358c264560662793ff72bfcc57d3d155b5b.tar.gz project-s-1f534358c264560662793ff72bfcc57d3d155b5b.zip |
Implement Goo Gun primary fire
Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to 'assets/characters/base_character')
-rw-r--r-- | assets/characters/base_character/BaseCharacter.gd | 15 | ||||
-rw-r--r-- | assets/characters/base_character/BaseCharacter.tscn | 4 |
2 files changed, 18 insertions, 1 deletions
diff --git a/assets/characters/base_character/BaseCharacter.gd b/assets/characters/base_character/BaseCharacter.gd new file mode 100644 index 0000000..bcc0f26 --- /dev/null +++ b/assets/characters/base_character/BaseCharacter.gd @@ -0,0 +1,15 @@ +extends KinematicBody + +export var is_firing = false +export var look_angle = 0 +export var weapon_pitch = 0 +export var weapon_pitch_bias = deg2rad(20) + +func _process(_delta): + var effective_weapon_pitch = weapon_pitch - weapon_pitch_bias if is_firing else weapon_pitch + effective_weapon_pitch = clamp(effective_weapon_pitch, deg2rad(-90), deg2rad(90)) + $GooGun.is_firing = is_firing + $GooGun.look_angle = look_angle + $GooGun.weapon_pitch = effective_weapon_pitch + $GooGun.rotation.x = effective_weapon_pitch + rotation.y = look_angle diff --git a/assets/characters/base_character/BaseCharacter.tscn b/assets/characters/base_character/BaseCharacter.tscn index 191e581..7b22f63 100644 --- a/assets/characters/base_character/BaseCharacter.tscn +++ b/assets/characters/base_character/BaseCharacter.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://assets/weapons/goo_gun/GooGun.tscn" type="PackedScene" id=1] [ext_resource path="res://assets/characters/base_character/friendly_material.tres" type="Material" id=2] +[ext_resource path="res://assets/characters/base_character/BaseCharacter.gd" type="Script" id=3] [sub_resource type="CapsuleMesh" id=1] material = ExtResource( 2 ) @@ -13,6 +14,7 @@ radius = 0.3 height = 0.9 [node name="BaseCharacter" type="KinematicBody"] +script = ExtResource( 3 ) [node name="Body" type="MeshInstance" parent="."] transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0 ) |