Init the godot project
- Add a first-view controller and a bunch of things - First shooting implementation - Remove heavy models and clean the project up
This commit is contained in:
27
scenes/weapon/bullet.gd
Normal file
27
scenes/weapon/bullet.gd
Normal file
@ -0,0 +1,27 @@
|
||||
extends Node3D
|
||||
|
||||
const SPEED = 100
|
||||
|
||||
@onready var mesh = $MeshInstance3D
|
||||
@onready var ray = $RayCast3D
|
||||
@onready var particles = $GPUParticles3D
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
position += transform.basis * Vector3(0, 0, SPEED) * delta
|
||||
ray.collision_mask = 1
|
||||
ray.enabled = 1
|
||||
if ray.is_colliding():
|
||||
mesh.visible = false
|
||||
particles.emitting = true
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_timer_timeout():
|
||||
queue_free()
|
56
scenes/weapon/bullet.tscn
Normal file
56
scenes/weapon/bullet.tscn
Normal file
@ -0,0 +1,56 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://b0agqeg53tey5"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/weapon/bullet.gd" id="1_th28m"]
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_vxst2"]
|
||||
size = Vector3(0.2, 0.2, 0.5)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_p8o05"]
|
||||
albedo_color = Color(0.894987, 0.000702324, 0.905119, 1)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ynv38"]
|
||||
albedo_color = Color(0.929412, 0, 0, 1)
|
||||
emission_enabled = true
|
||||
emission = Color(0.886321, 0.78611, 0.23507, 1)
|
||||
emission_energy_multiplier = 7.71
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_58cgi"]
|
||||
direction = Vector3(0, 0, 1)
|
||||
spread = 22.5
|
||||
initial_velocity_min = 3.47
|
||||
initial_velocity_max = 5.0
|
||||
gravity = Vector3(0, -19.6, 0)
|
||||
linear_accel_min = -6.67
|
||||
linear_accel_max = 6.67
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_mfkmi"]
|
||||
size = Vector3(0.05, 0.05, 0.05)
|
||||
|
||||
[node name="Bullet" type="Node3D"]
|
||||
script = ExtResource("1_th28m")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(0.663102, 0, 0, 0, 0.601826, 0, 0, 0, 0.58984, 0, 0, 0)
|
||||
mesh = SubResource("BoxMesh_vxst2")
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_p8o05")
|
||||
|
||||
[node name="RayCast3D" type="RayCast3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.100459)
|
||||
target_position = Vector3(0, 0, -0.5)
|
||||
|
||||
[node name="GPUParticles3D" type="GPUParticles3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.18476)
|
||||
material_override = SubResource("StandardMaterial3D_ynv38")
|
||||
emitting = false
|
||||
amount = 10
|
||||
one_shot = true
|
||||
explosiveness = 1.0
|
||||
process_material = SubResource("ParticleProcessMaterial_58cgi")
|
||||
draw_pass_1 = SubResource("BoxMesh_mfkmi")
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
wait_time = 10.0
|
||||
one_shot = true
|
||||
autostart = true
|
||||
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
5
scenes/weapon/deagle.tscn
Normal file
5
scenes/weapon/deagle.tscn
Normal 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")]
|
28
scenes/weapon/pistol.gd
Normal file
28
scenes/weapon/pistol.gd
Normal file
@ -0,0 +1,28 @@
|
||||
extends Node3D
|
||||
|
||||
var bullet = load("res://scenes/weapon/bullet.tscn")
|
||||
var instance
|
||||
|
||||
@onready var gun_anim = $Pistol/Deagle/GunAnimation
|
||||
#@onready var gun_barrel = $DEAGLE/CSGSphere3D
|
||||
@onready var gun_barrel = $Pistol/Deagle/RayCast3D
|
||||
|
||||
# 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 main_root = get_node("/root/TestMap")
|
||||
if Input.is_action_pressed("shot"):
|
||||
if !gun_anim.is_playing():
|
||||
gun_anim.play("Shoot")
|
||||
instance = bullet.instantiate()
|
||||
instance.position = gun_barrel.global_position
|
||||
instance.transform.basis = gun_barrel.global_transform.basis
|
||||
get_tree().get_root().add_child(instance)
|
||||
|
||||
# TODO: Handle the reload logic
|
||||
func reload():
|
||||
var pistol := $DEAGLE
|
||||
pistol.rotate_z(-20.0)
|
507
scenes/weapon/pistol.tscn
Normal file
507
scenes/weapon/pistol.tscn
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user