Implemented basic weapon switching
parent
751b369163
commit
021168a507
|
@ -39,6 +39,7 @@ var health = max_health:
|
|||
@onready var mesh = $Mesh
|
||||
|
||||
@onready var weapon = $Head/Camera/Hand/RocketLauncher
|
||||
var weapon_last = null
|
||||
|
||||
var gibs_vfx = preload("res://Assets/Effects/Gibs.tscn")
|
||||
var blood_decal = preload("res://Assets/Decals/Blood/BloodSplash.tscn")
|
||||
|
@ -209,9 +210,8 @@ func view_banner(show:bool):
|
|||
return
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
weapon.show()
|
||||
|
||||
set_weapon(0) # starter weapon
|
||||
|
||||
#Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
view_zoom_target = 1.0
|
||||
|
||||
|
@ -246,6 +246,21 @@ func aim(event) -> void:
|
|||
current_tilt -= deg2rad(mouse_motion.relative.y * adjusted_mouse_sensitivity / view_zoom)
|
||||
head.rotation.x = clamp(current_tilt, deg2rad(-90), deg2rad(90))
|
||||
|
||||
@rpc(authority, reliable, call_local) func set_weapon(index) -> void: # index of -1 will swithc to last used weapon
|
||||
var new_weapon
|
||||
|
||||
if weapon:
|
||||
weapon_last = weapon
|
||||
weapon.hide()
|
||||
|
||||
if index == -1:
|
||||
new_weapon = weapon_last
|
||||
else:
|
||||
new_weapon = $Head/Camera/Hand.get_child(index)
|
||||
|
||||
weapon = new_weapon
|
||||
weapon.show() # show new weapon
|
||||
|
||||
func _input(event) -> void:
|
||||
if dead:
|
||||
return
|
||||
|
@ -253,6 +268,14 @@ func _input(event) -> void:
|
|||
if not input_active:
|
||||
return
|
||||
|
||||
# weapon switching
|
||||
if Input.is_action_just_pressed("weapon_1"):
|
||||
rpc(&'set_weapon', 0)
|
||||
elif Input.is_action_just_pressed("weapon_2"):
|
||||
rpc(&'set_weapon', 1)
|
||||
elif Input.is_action_just_pressed("weapon_last"):
|
||||
rpc(&'set_weapon', -1)
|
||||
|
||||
#assert(is_multiplayer_authority() == true, "input_active is true, even though the node is not multiplayer_authority")
|
||||
if is_multiplayer_authority() == false:
|
||||
print("Input is active, but we're not the authority. WTF?!")
|
||||
|
|
|
@ -266,10 +266,10 @@ fov = 90.0
|
|||
[node name="Hand" type="Node3D" parent="Head/Camera"]
|
||||
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0.3, -0.4, -0.6)
|
||||
|
||||
[node name="RocketLauncher" parent="Head/Camera/Hand" instance=ExtResource( "4_wnkv6" )]
|
||||
[node name="Handgun" parent="Head/Camera/Hand" instance=ExtResource( "4_7tta1" )]
|
||||
visible = false
|
||||
|
||||
[node name="Handgun" parent="Head/Camera/Hand" instance=ExtResource( "4_7tta1" )]
|
||||
[node name="RocketLauncher" parent="Head/Camera/Hand" instance=ExtResource( "4_wnkv6" )]
|
||||
visible = false
|
||||
|
||||
[node name="Tween" type="Node" parent="Head/Camera"]
|
||||
|
|
|
@ -229,6 +229,30 @@ tracks/2/keys = {
|
|||
"transitions": PackedFloat32Array(),
|
||||
"values": []
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/path = NodePath("GPUParticlesAttractorSphere3D:radius")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.01]
|
||||
}
|
||||
tracks/4/type = "value"
|
||||
tracks/4/imported = false
|
||||
tracks/4/enabled = true
|
||||
tracks/4/path = NodePath("GPUParticlesAttractorSphere3D:strength")
|
||||
tracks/4/interp = 1
|
||||
tracks/4/loop_wrap = true
|
||||
tracks/4/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="8"]
|
||||
resource_name = "anim"
|
||||
|
@ -271,6 +295,30 @@ tracks/2/keys = {
|
|||
"method": &"queue_free"
|
||||
}]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = false
|
||||
tracks/3/path = NodePath("GPUParticlesAttractorSphere3D:strength")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.45),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, -5.0, -2.0]
|
||||
}
|
||||
tracks/4/type = "value"
|
||||
tracks/4/imported = false
|
||||
tracks/4/enabled = false
|
||||
tracks/4/path = NodePath("GPUParticlesAttractorSphere3D:radius")
|
||||
tracks/4/interp = 1
|
||||
tracks/4/loop_wrap = true
|
||||
tracks/4/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.45, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [0.01, 1.0, 2.0, 3.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_itp5v"]
|
||||
length = 0.001
|
||||
|
@ -382,6 +430,10 @@ tracks/4/keys = {
|
|||
[node name="Impact" type="Node3D"]
|
||||
script = ExtResource( "1_7cd22" )
|
||||
|
||||
[node name="GPUParticlesAttractorSphere3D" type="GPUParticlesAttractorSphere3D" parent="."]
|
||||
strength = 0.0
|
||||
radius = 0.01
|
||||
|
||||
[node name="Explosion" type="GPUParticles3D" parent="."]
|
||||
layers = 2
|
||||
emitting = false
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=10 format=3 uid="uid://ikiqohjvlqni"]
|
||||
[gd_scene load_steps=17 format=3 uid="uid://ikiqohjvlqni"]
|
||||
|
||||
[ext_resource type="Script" path="res://Assets/Weapons/Handgun/Flash.gd" id="1_ob70b"]
|
||||
[ext_resource type="Texture2D" uid="uid://pnh872qjk0oy" path="res://Assets/Effects/Flame.png" id="2_1simy"]
|
||||
|
@ -37,6 +37,57 @@ tracks/0/keys = {
|
|||
"values": [Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_jrhpo"]
|
||||
interpolation_mode = 2
|
||||
offsets = PackedFloat32Array(0, 0.0422535, 0.122066, 0.211268, 0.319249, 1)
|
||||
colors = PackedColorArray(0, 0, 0, 1, 3, 2.4, 0.4, 1, 1.78272, 1.24586, 0.237743, 1, 1.38889, 0.872464, 0.185248, 1, 1, 0.503748, 0.133411, 1, 0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="GradientTexture1D" id="GradientTexture1D_lue3h"]
|
||||
gradient = SubResource( "Gradient_jrhpo" )
|
||||
use_hdr = true
|
||||
|
||||
[sub_resource type="Curve" id="Curve_vfbna"]
|
||||
_data = [Vector2(0, 0.154545), 0.0, 5.74743, 0, 0, Vector2(0.157761, 0.6), 1.49824, 1.49824, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_n25a7"]
|
||||
curve = SubResource( "Curve_vfbna" )
|
||||
|
||||
[sub_resource type="ParticlesMaterial" id="ParticlesMaterial_fglo4"]
|
||||
lifetime_randomness = 0.25
|
||||
direction = Vector3(0, 0, -1)
|
||||
spread = 5.0
|
||||
gravity = Vector3(0, 0, 0)
|
||||
initial_velocity_min = 5.0
|
||||
initial_velocity_max = 10.0
|
||||
angular_velocity_min = -5.0
|
||||
angular_velocity_max = 5.0
|
||||
damping_min = 20.0
|
||||
damping_max = 26.0
|
||||
angle_min = -180.0
|
||||
angle_max = 180.0
|
||||
scale_min = 2.0
|
||||
scale_max = 2.5
|
||||
scale_curve = SubResource( "CurveTexture_n25a7" )
|
||||
color_ramp = SubResource( "GradientTexture1D_lue3h" )
|
||||
anim_offset_max = 4.0
|
||||
collision_enabled = true
|
||||
collision_friction = 1.0
|
||||
collision_use_scale = true
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_gjqv3"]
|
||||
blend_mode = 1
|
||||
shading_mode = 0
|
||||
vertex_color_use_as_albedo = true
|
||||
albedo_texture = ExtResource( "2_1simy" )
|
||||
billboard_mode = 3
|
||||
particles_anim_h_frames = 2
|
||||
particles_anim_v_frames = 2
|
||||
particles_anim_loop = false
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_o6i5g"]
|
||||
material = SubResource( "StandardMaterial3D_gjqv3" )
|
||||
size = Vector2(0.3, 0.3)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="6"]
|
||||
blend_mode = 1
|
||||
shading_mode = 0
|
||||
|
@ -68,7 +119,14 @@ anims/Flash = SubResource( "1" )
|
|||
anims/Off = SubResource( "2" )
|
||||
anims/RESET = SubResource( "3" )
|
||||
|
||||
[node name="GPUParticles3D" type="GPUParticles3D" parent="."]
|
||||
explosiveness = 1.0
|
||||
fixed_fps = 0
|
||||
process_material = SubResource( "ParticlesMaterial_fglo4" )
|
||||
draw_pass_1 = SubResource( "QuadMesh_o6i5g" )
|
||||
|
||||
[node name="CPUParticles3D" type="CPUParticles3D" parent="."]
|
||||
visible = false
|
||||
emitting = false
|
||||
lifetime = 0.15
|
||||
one_shot = true
|
||||
|
|
|
@ -99,8 +99,8 @@ func _on_Area3D_body_entered(body):
|
|||
$OmniLight3D/Smoke.emitting = false
|
||||
$Area3D.queue_free()
|
||||
$Rocket.queue_free()
|
||||
$Timer2.start()
|
||||
$AmbientSound.stop()
|
||||
$Timer2.start()
|
||||
|
||||
func _on_Timer_timeout():
|
||||
queue_free()
|
||||
|
|
Reference in New Issue