Reworked gib with particle collisions to test how they work. Fixed player damage feedback, but death is still bugged.
This commit is contained in:
parent
6aef66c0a8
commit
953c859098
9 changed files with 193 additions and 39 deletions
|
@ -101,6 +101,8 @@ var dead = false: # used to workaround Godot crash when destroying player_nodes
|
|||
#input_active = false
|
||||
self.hide()
|
||||
$Body.disabled = true
|
||||
hud.pain = 4
|
||||
crosshair.hide()
|
||||
#set_physics_process(false)
|
||||
false:
|
||||
#input_active = true
|
||||
|
@ -108,6 +110,8 @@ var dead = false: # used to workaround Godot crash when destroying player_nodes
|
|||
$Body.disabled = false
|
||||
$SpawnSFX.play()
|
||||
$SpawnVFX.emitting = true
|
||||
hud.pain = 0
|
||||
crosshair.show()
|
||||
#set_physics_process(true)
|
||||
dead = value
|
||||
var focus_banner_alpha = 0
|
||||
|
@ -145,6 +149,37 @@ func view_banner(show:bool):
|
|||
# print("Rebroadcasting RPC call for set_dead ", dead)
|
||||
# rpc(&'set_dead', dead)
|
||||
|
||||
@rpc(any_peer, reliable) func damage_feedback(kill=false):
|
||||
if is_multiplayer_authority():
|
||||
var victim = get_tree().multiplayer.get_remote_sender_id()
|
||||
if kill:
|
||||
crosshair.kill()
|
||||
|
||||
var pid = get_multiplayer_authority()
|
||||
main.player_list.players[pid].score += 1 # we get a point
|
||||
main.rpc(&'player_list_update', main.player_list.get(pid).serialize(), pid) # tell everyone
|
||||
|
||||
main.check_game_win_condition()
|
||||
|
||||
# check for firstblood
|
||||
if main.player_list.players[pid].score == 1:
|
||||
var firstblood = true
|
||||
for i in main.player_list.players.keys():
|
||||
if i != pid and main.player_list.players[i].score > 0:
|
||||
firstblood = false
|
||||
if firstblood:
|
||||
main.get_node("Announcer").speak(main.get_node("Announcer").firstblood) # design a proper API
|
||||
|
||||
# check for revenge (payback) - don't play if this is a duel, it'd be silly
|
||||
if main.player_list.players.size() > 2 and victim == revenge_pid:
|
||||
main.get_node("Announcer").speak(main.get_node("Announcer").payback)
|
||||
revenge_pid = -1 # reset revenge
|
||||
else:
|
||||
crosshair.hit()
|
||||
else:
|
||||
print("damage feedback called on puppet, ignoring")
|
||||
return
|
||||
|
||||
func _ready() -> void:
|
||||
#Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
view_zoom_target = 1.0
|
||||
|
@ -279,23 +314,29 @@ func _process(delta):
|
|||
@rpc(call_local, any_peer, reliable) func moan():
|
||||
var anims = ["01", "02", "03", "04"]
|
||||
$Pain.play(anims[randi() % 4])
|
||||
|
||||
@rpc(call_local, any_peer, reliable) func _damage(hp: int):
|
||||
if is_multiplayer_authority():
|
||||
hud.damage(hp)
|
||||
|
||||
|
||||
|
||||
#moan()
|
||||
@rpc(call_local, any_peer, reliable) func take_damage(attacker: int, hit_position: Vector3, hit_normal: Vector3, damage:int, source_position: Vector3, damage_type, push: float):
|
||||
var attacker_node = main.get_node("Players").get_node(str(attacker))
|
||||
|
||||
@rpc(call_local, any_peer, reliable) func take_damage(attacker, hit_position: Vector3, hit_normal: Vector3, damage:int, source_position: Vector3, damage_type, push: float):
|
||||
if is_multiplayer_authority():
|
||||
print("Taken damage: ", damage, " by: ", attacker, " from: ", source_position)
|
||||
hud.damage(damage)
|
||||
main.player_list.players[self.get_multiplayer_authority()].health -= damage # reduce health
|
||||
main.push_local_player_info()
|
||||
|
||||
print("Got some damage, but I'm just a puppet so whatever!")
|
||||
if main.player_list.players[self.get_multiplayer_authority()].health <= 0: # are we dead?
|
||||
print("Died")
|
||||
rpc(&'die', attacker)
|
||||
|
||||
attacker_node.rpc(&'damage_feedback', true) # let the attacker know he's got a kill
|
||||
else:
|
||||
attacker_node.rpc(&'damage_feedback', false) # let the attackr know he's got a hit
|
||||
|
||||
main.update_hud()
|
||||
|
||||
if not dead:
|
||||
rpc(&'moan') # all puppets must scream!
|
||||
|
||||
|
||||
@rpc(any_peer, call_local, reliable) func die(killer_pid: int):
|
||||
var gibs = gibs_vfx.instantiate()
|
||||
|
|
|
@ -250,6 +250,12 @@ target_position = Vector3(0, 0, -1000)
|
|||
collision_mask = 2
|
||||
script = null
|
||||
|
||||
[node name="GPUParticlesCollisionSphere" type="GPUParticlesCollisionSphere" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 2.16632, 0, 0, 0, 1, 0.00910211, 0.760577, 0.00278068)
|
||||
layers = 7
|
||||
radius = 0.549216
|
||||
script = null
|
||||
|
||||
[node name="Body" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.852763, 0)
|
||||
shape = SubResource( "2" )
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
extends CPUParticles3D
|
||||
extends Node3D
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
|
@ -8,13 +8,12 @@ extends CPUParticles3D
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
emitting = true
|
||||
$Gibs.emitting = true
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
|
||||
|
||||
func _on_Timer_timeout():
|
||||
queue_free()
|
||||
|
|
|
@ -1,39 +1,107 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://egphnvwk6cg"]
|
||||
[gd_scene load_steps=16 format=3 uid="uid://egphnvwk6cg"]
|
||||
|
||||
[ext_resource type="Script" path="res://Assets/Effects/Gibs.gd" id="1_o0guu"]
|
||||
[ext_resource type="PackedScene" uid="uid://c5cwnfuw4go1b" path="res://Assets/Audio/SoundPlayer.tscn" id="2_3tb4k"]
|
||||
[ext_resource type="AudioStream" uid="uid://xv1jp0gql8tc" path="res://Assets/SFX/Player_Death_01.wav" id="3_hmhtq"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_3sp1q"]
|
||||
albedo_color = Color(0.509804, 0.0235294, 0, 1)
|
||||
roughness = 0.26
|
||||
[sub_resource type="Gradient" id="Gradient_tjffd"]
|
||||
offsets = PackedFloat32Array(0, 0.874302, 1)
|
||||
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0)
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_riydg"]
|
||||
material = SubResource( "StandardMaterial3D_3sp1q" )
|
||||
[sub_resource type="GradientTexture" id="GradientTexture_07eoi"]
|
||||
gradient = SubResource( "Gradient_tjffd" )
|
||||
|
||||
[sub_resource type="ParticlesMaterial" id="ParticlesMaterial_jcugi"]
|
||||
lifetime_randomness = 0.15
|
||||
emission_shape = 1
|
||||
emission_sphere_radius = 0.5
|
||||
spread = 180.0
|
||||
initial_velocity_min = 1.0
|
||||
initial_velocity_max = 8.0
|
||||
color_ramp = SubResource( "GradientTexture_07eoi" )
|
||||
sub_emitter_mode = 1
|
||||
sub_emitter_frequency = 100.0
|
||||
sub_emitter_keep_velocity = true
|
||||
collision_enabled = true
|
||||
collision_friction = 0.31
|
||||
collision_bounce = 0.58
|
||||
|
||||
[sub_resource type="OpenSimplexNoise" id="OpenSimplexNoise_tchuy"]
|
||||
octaves = 2
|
||||
period = 16.0
|
||||
|
||||
[sub_resource type="NoiseTexture" id="NoiseTexture_ixngr"]
|
||||
width = 64
|
||||
height = 64
|
||||
as_normal_map = true
|
||||
noise = SubResource( "OpenSimplexNoise_tchuy" )
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nvuyc"]
|
||||
transparency = 1
|
||||
vertex_color_use_as_albedo = true
|
||||
albedo_color = Color(1, 0.0235294, 0, 1)
|
||||
roughness = 0.14
|
||||
normal_enabled = true
|
||||
normal_texture = SubResource( "NoiseTexture_ixngr" )
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_ctp33"]
|
||||
material = SubResource( "StandardMaterial3D_nvuyc" )
|
||||
radius = 0.1
|
||||
height = 0.2
|
||||
radial_segments = 8
|
||||
rings = 8
|
||||
rings = 4
|
||||
|
||||
[sub_resource type="Curve" id="Curve_0e5oj"]
|
||||
_data = [Vector2(0.00694444, 0.954545), 0.0, 0.0, 0, 0, Vector2(1, 0), -2.07914, 0.0, 0, 0]
|
||||
[sub_resource type="Gradient" id="Gradient_roxnd"]
|
||||
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
|
||||
|
||||
[node name="GPUParticles3D" type="CPUParticles3D"]
|
||||
[sub_resource type="GradientTexture" id="GradientTexture_jtdpg"]
|
||||
gradient = SubResource( "Gradient_roxnd" )
|
||||
|
||||
[sub_resource type="ParticlesMaterial" id="ParticlesMaterial_6gu8h"]
|
||||
color_ramp = SubResource( "GradientTexture_jtdpg" )
|
||||
collision_enabled = true
|
||||
collision_friction = 0.93
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_u05mr"]
|
||||
transparency = 1
|
||||
vertex_color_use_as_albedo = true
|
||||
albedo_color = Color(1, 0.00784314, 0, 1)
|
||||
roughness = 0.14
|
||||
billboard_mode = 3
|
||||
particles_anim_h_frames = 1
|
||||
particles_anim_v_frames = 1
|
||||
particles_anim_loop = false
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_ho3xr"]
|
||||
material = SubResource( "StandardMaterial3D_u05mr" )
|
||||
size = Vector2(0.1, 0.1)
|
||||
|
||||
[node name="GibbsEffect" type="Node3D"]
|
||||
script = ExtResource( "1_o0guu" )
|
||||
|
||||
[node name="Gibs" type="GPUParticles3D" parent="."]
|
||||
layers = 4
|
||||
emitting = false
|
||||
amount = 32
|
||||
amount = 128
|
||||
sub_emitter = NodePath("../Blood")
|
||||
lifetime = 5.0
|
||||
one_shot = true
|
||||
explosiveness = 1.0
|
||||
fixed_fps = 30
|
||||
mesh = SubResource( "SphereMesh_riydg" )
|
||||
emission_shape = 3
|
||||
emission_points = PackedVector3Array(0.213792, 0.293558, -0.239298, -0.12737, 0.631196, -0.141563, 0.192791, 0.151973, -0.137897, 0.359606, 0.947813, -0.0768365, 0.194725, 0.587412, 0.214862, -0.0413049, 0.633023, 0.337953, -0.190239, 0.734695, -0.213316, 0.398734, 0.954908, -0.0184722, -0.0121239, 1.4246, -0.0232558, -0.0535609, 1.64598, -0.121451, 0.16018, 0.432162, 0.137138, 0.28397, 0.802465, 0.273994, -0.086569, 0.331748, -0.373907, 0.151013, 1.00774, 0.106493, 0.0316862, 0.78307, -0.0015597, 0.0137127, 1.32038, 0.186835, 0.354167, 0.429079, 0.0606308, 0.308906, 0.195378, -0.112554, 0.162532, 0.712726, -0.0580729, -0.148121, 0.258527, 0.196588, 0.121123, 0.125489, -0.0131164, -0.268994, 1.3866, -0.170491, -0.321323, 1.14779, 0.0402509, -0.0245586, 1.1546, -0.340647, 0.168819, 0.119007, 0.210639, 0.390349, 1.22382, 0.066388, 0.226391, 0.449593, 0.211008, 0.091519, 1.4079, 0.278107, -0.111734, 0.672877, 0.363257, -0.122951, 1.37178, 0.0514085, -0.265176, 0.408875, 0.23233, 0.138502, 0.247815, -0.282018, 0.158044, 1.35905, -0.301838, -0.0117804, 1.42503, -0.372285, -0.266539, 1.25614, 0.211245, 0.0765518, 0.871181, 0.13197, 0.0944997, 0.234855, 0.255727, -0.147605, 0.149461, 0.102494, -0.041316, 0.119079, 0.0632052, 0.0285764, 0.862697, -0.291928, 0.153573, 0.875813, 0.240219, -0.094903, 1.24591, 0.331878, -0.300984, 1.10989, 0.25754, 0.0280152, 0.227853, 0.305782, 0.144829, 1.13028, 0.247458, -0.297053, 1.33953, -0.25212, 0.255629, 0.426613, 0.175493, 0.180825, 0.921968, 0.333394, 0.0429266, 1.29984, 0.137121, 0.120818, 1.0851, 0.0890484, -0.246802, 0.314922, 0.118292, -0.0702293, 0.131391, 0.121838, 0.107325, 0.777287, -0.322295, 0.112643, 0.932287, 0.36087, 0.212013, 1.29013, 0.190726, 0.131307, 1.25809, -0.342333, -0.144784, 0.574611, 0.270844, 0.00399578, 1.25063, 0.228666, 0.109936, 1.47567, -0.0186085, 0.382821, 0.989886, 0.0529952, -0.11686, 1.24431, -0.363027, 0.209045, 1.60135, 0.0683457, 0.0921369, 0.784928, 0.151519, -0.0889999, 0.839174, -0.367262, 0.135316, 1.26909, 0.227138, -0.168382, 1.46148, -0.0122506, 0.227487, 0.604992, -0.244163, 0.263066, 0.41004, -0.200542, -0.181149, 0.957524, 0.186846, 0.313458, 1.23143, -0.0450301, 0.0249283, 1.27376, -0.180561, -0.229117, 1.24942, 0.279538, 0.181303, 1.1398, 0.164216, 0.201891, 1.54447, 0.025169, -0.301608, 1.20045, -0.0241991, 0.293079, 0.852535, 0.186271, 0.270674, 0.626333, 0.141311, 0.185143, 1.56542, -0.0231146, -0.183985, 0.855768, -0.109044, 0.220596, 0.85369, 0.184708, 0.0326539, 0.670344, -0.201186, 0.0935103, 0.36576, 0.332694, 0.0295326, 0.784154, 0.378336, -0.164651, 0.72306, -0.0226527, -0.22198, 1.50055, 0.117691, -0.0424937, 1.2494, 0.370492, 0.0782578, 1.0032, 0.115449, 0.143578, 0.950895, -0.00153738, 0.125742, 1.09669, 0.266231, -0.0031639, 0.0938585, -0.158077, 0.25241, 0.81581, 0.299586, 0.0682948, 0.329631, -0.0851988, -0.12918, 0.248223, -0.337992, 0.0366944, 0.303778, -0.345714, -0.240697, 0.608311, -0.178695, -0.0507606, 0.581082, 0.372165, -0.00363311, 0.193522, -0.306941, 0.0744256, 1.12727, -0.269475, -0.0880248, 0.306396, -0.124157, -0.383416, 1.34143, -0.091211, 0.0435722, 1.22679, -0.0277889, -0.154645, 0.629385, 0.334208, -0.136264, 0.312748, 0.340147, -0.0730954, 0.160824, -0.122244, -0.0656257, 0.292709, 0.18593, -0.233391, 0.599557, -0.117712, 0.359666, 1.42768, 0.00898111, 0.165606, 1.24167, -0.0305199, 0.0108935, 0.376355, -0.277372, 0.147166, 0.616227, 0.295277, -0.248208, 0.167717, -0.0723494, 0.223818, 1.35089, 0.0880279, -0.146517, 0.91615, 0.224953, 0.0213891, 1.30633, -0.0351697, -0.0157524, 1.48568, -0.181715, -0.0318395, 0.490449, -0.0141865, -0.219646, 0.944284, -0.0685343, -0.258311, 1.24031, 0.0813233, 0.161967, 1.239, -0.352594, 0.339281, 0.426037, -0.0404075, -0.198885, 1.35612, 0.102736, -0.00542265, 1.01909, -0.309931, -0.127917, 0.110843, -0.201308, 0.0107117, 0.113423, 0.0182374, -0.161015, 0.224641, -0.297972, 0.301496, 0.932366, -0.242365, 0.216504, 1.2761, -0.256302, -0.282683, 0.924247, 0.257186)
|
||||
spread = 180.0
|
||||
initial_velocity_min = 1.0
|
||||
initial_velocity_max = 4.0
|
||||
scale_amount_curve = SubResource( "Curve_0e5oj" )
|
||||
script = ExtResource( "1_o0guu" )
|
||||
fixed_fps = 0
|
||||
collision_base_size = 0.1
|
||||
process_material = SubResource( "ParticlesMaterial_jcugi" )
|
||||
draw_pass_1 = SubResource( "SphereMesh_ctp33" )
|
||||
script = null
|
||||
|
||||
[node name="Blood" type="GPUParticles3D" parent="."]
|
||||
visible = false
|
||||
amount = 16
|
||||
lifetime = 0.82
|
||||
randomness = 0.22
|
||||
fixed_fps = 0
|
||||
process_material = SubResource( "ParticlesMaterial_6gu8h" )
|
||||
draw_pass_1 = SubResource( "QuadMesh_ho3xr" )
|
||||
script = null
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
wait_time = 5.0
|
||||
|
|
|
@ -72,4 +72,6 @@ func _process(delta):
|
|||
if $ScoreTable.visible: # update the scores every frame when player is watching the score table
|
||||
update_scoretab()
|
||||
|
||||
pain *= 1 - delta
|
||||
if main.local_player:
|
||||
if not main.local_player.dead:
|
||||
pain *= 1 - delta # time heals pain, as long as you're alive
|
||||
|
|
BIN
Game/Assets/Maps/DM1/ParticlesCollisionSDF.exr
Normal file
BIN
Game/Assets/Maps/DM1/ParticlesCollisionSDF.exr
Normal file
Binary file not shown.
26
Game/Assets/Maps/DM1/ParticlesCollisionSDF.exr.import
Normal file
26
Game/Assets/Maps/DM1/ParticlesCollisionSDF.exr.import
Normal file
|
@ -0,0 +1,26 @@
|
|||
[remap]
|
||||
|
||||
importer="3d_texture"
|
||||
type="StreamTexture3D"
|
||||
uid="uid://dp74htl3lpbqu"
|
||||
path="res://.godot/imported/ParticlesCollisionSDF.exr-b07a292fdeca169c4ad7fd6c426ef1b8.stex3d"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Assets/Maps/DM1/ParticlesCollisionSDF.exr"
|
||||
dest_files=["res://.godot/imported/ParticlesCollisionSDF.exr-b07a292fdeca169c4ad7fd6c426ef1b8.stex3d"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=3
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/bptc_ldr=0
|
||||
compress/channel_pack=1
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
slices/horizontal=1
|
||||
slices/vertical=111
|
|
@ -59,10 +59,10 @@ var spread = spread_min
|
|||
casing_instance.angular_velocity.y += randf_range(-10, 10)
|
||||
casing_instance.angular_velocity.x += randf_range(-10, 10)
|
||||
|
||||
pass
|
||||
|
||||
if is_multiplayer_authority(): # only do this on the attacker's local instance of the game
|
||||
give_damage(ray['collider'], ray['position'], ray['normal'], 20, self.global_transform.origin, Globals.DamageType.BULLET, 1.0)
|
||||
|
||||
if ray:
|
||||
if is_multiplayer_authority(): # only do this on the attacker's local instance of the game
|
||||
give_damage(ray['collider'], ray['position'], ray['normal'], 20, self.global_transform.origin, Globals.DamageType.BULLET, 1.0)
|
||||
|
||||
return # skip the rest - it's deprecated code
|
||||
|
||||
|
@ -120,7 +120,7 @@ var spread = spread_min
|
|||
|
||||
func give_damage(target: Node, hit_position: Vector3, hit_normal: Vector3, damage: int, source_position: Vector3, type: Globals.DamageType, push: float):
|
||||
if target.has_method(&'take_damage'): # we've hit a player or something else - the ywill handle everything like effects etc.
|
||||
target.rpc(&'take_damage', player, hit_position, hit_normal, damage, source_position, type, push)
|
||||
target.rpc(&'take_damage', get_multiplayer_authority(), hit_position, hit_normal, damage, source_position, type, push)
|
||||
else:
|
||||
pass # TODO take data from the material of the target and spawn an appropriate hit effect
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=23 format=3 uid="uid://b1078bn8gy2qf"]
|
||||
[gd_scene load_steps=24 format=3 uid="uid://b1078bn8gy2qf"]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://Assets/MapComponents/SpawnPoint.tscn" id="1"]
|
||||
[ext_resource type="PackedScene" uid="uid://caipucfu7hjkk" path="res://Assets/Props/BeerCan.tscn" id="1_ecbkv"]
|
||||
|
@ -9,6 +9,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://d24tv4e0dptk0" path="res://Assets/Effects/Logo.png" id="4_mci55"]
|
||||
[ext_resource type="Script" path="res://Assets/Decals/Logo.gd" id="5_yr76j"]
|
||||
[ext_resource type="PackedScene" uid="uid://w476ulvte1f6" path="res://Assets/Maps/DM1/DM1.glb" id="6"]
|
||||
[ext_resource type="StreamTexture3D" uid="uid://dp74htl3lpbqu" path="res://Assets/Maps/DM1/ParticlesCollisionSDF.exr" id="10_2c624"]
|
||||
|
||||
[sub_resource type="OpenSimplexNoise" id="OpenSimplexNoise_8aprf"]
|
||||
octaves = 6
|
||||
|
@ -448,4 +449,15 @@ current = true
|
|||
fov = 60.0
|
||||
script = null
|
||||
|
||||
[node name="GPUParticlesCollisionSDF" type="GPUParticlesCollisionSDF" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7.22556, 9.57059, 0)
|
||||
cull_mask = 4293918721
|
||||
extents = Vector3(26.1656, 14.931, 22.8541)
|
||||
resolution = 3
|
||||
texture = ExtResource( "10_2c624" )
|
||||
script = null
|
||||
__meta__ = {
|
||||
"_edit_lock_": true
|
||||
}
|
||||
|
||||
[editable path="DM1"]
|
||||
|
|
Reference in a new issue