Add shot and reload actions

This commit is contained in:
2025-01-16 17:42:44 +01:00
parent 7b0de72911
commit 7ec7cf189c
8 changed files with 86 additions and 7 deletions

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://ccm77j5rkh21w"]
[gd_scene load_steps=6 format=3 uid="uid://ccm77j5rkh21w"]
[ext_resource type="Script" path="res://scripts/character_controller.gd" id="1_sue4n"]
[ext_resource type="PackedScene" uid="uid://d21giy40pnjhe" path="res://scenes/weapon/pistol.tscn" id="2_blr4e"]
[ext_resource type="Texture2D" uid="uid://d1nfjip21kjpu" path="res://addons/kenney_prototype_textures/orange/texture_13.png" id="2_i60ip"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_m6bjf"]
@ -17,12 +18,18 @@ script = ExtResource("1_sue4n")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.975222, 0)
material_override = SubResource("StandardMaterial3D_m6bjf")
[node name="CameraMount" type="Node3D" parent="CharacterBody3D/Body"]
transform = Transform3D(1, 0, 0, 0, 0.999971, 0.00759248, 0, -0.00759248, 0.999971, 0, 0.951, 0)
[node name="UpperTorso" type="CSGSphere3D" parent="CharacterBody3D/Body"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.298181, 0)
[node name="Camera" type="Camera3D" parent="CharacterBody3D/Body/CameraMount"]
[node name="CameraMount" type="Node3D" parent="CharacterBody3D/Body/UpperTorso"]
transform = Transform3D(1, 0, 0, 0, 0.999971, 0.00759248, 0, -0.00759248, 0.999971, 0, 0.212444, 0)
[node name="Camera" type="Camera3D" parent="CharacterBody3D/Body/UpperTorso/CameraMount"]
transform = Transform3D(1, 0, 0, 0, 1, -4.65661e-10, 0, 0, 1, 0, 0.0051769, -0.68182)
[node name="Pistol" parent="CharacterBody3D/Body/UpperTorso" instance=ExtResource("2_blr4e")]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0.26718, -0.000199199, -0.945376)
[node name="CollisionShape3D" type="CollisionShape3D" parent="CharacterBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.981342, 0)
shape = SubResource("CylinderShape3D_1sre5")

View File

@ -0,0 +1,5 @@
[gd_scene load_steps=2 format=3 uid="uid://b50vg1umdgjas"]
[ext_resource type="PackedScene" uid="uid://dumj5qqh2h2tg" path="res://assets/models/weapon/DEAGLE/DEAGLE.glb" id="1_5xic7"]
[node name="DEAGLE" instance=ExtResource("1_5xic7")]

21
scenes/weapon/pistol.gd Normal file
View File

@ -0,0 +1,21 @@
extends Node3D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# TODO: Handle the shot logic
func shot():
var pistol := $DEAGLE
pistol.rotate_z(20.0)
# TODO: Handle the reload logic
func reload():
var pistol := $DEAGLE
pistol.rotate_z(-20.0)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass

View File

@ -0,0 +1,9 @@
[gd_scene load_steps=3 format=3 uid="uid://d21giy40pnjhe"]
[ext_resource type="PackedScene" uid="uid://dumj5qqh2h2tg" path="res://assets/models/weapon/DEAGLE/DEAGLE.glb" id="1_ard7n"]
[ext_resource type="Script" path="res://scenes/weapon/pistol.gd" id="1_jgbvq"]
[node name="Pistol" type="Node3D"]
script = ExtResource("1_jgbvq")
[node name="DEAGLE" parent="." instance=ExtResource("1_ard7n")]