Made some HUD elements visible even in menu. Made player head fall to the ground on death. Tweaked Gibs. Implemented gun bob. Fixed Player Body not casting shadows.

damage
unfa 2021-10-16 02:07:19 +02:00
parent 953c859098
commit 1b2375b3d4
5 changed files with 77 additions and 10 deletions

View File

@ -14,11 +14,11 @@ extends CharacterBody3D
@onready var head = $Head @onready var head = $Head
@onready var camera = $Head/Camera @onready var camera = $Head/Camera
@onready var tween = $Head/Camera/Tween #@onready var tween = $Head/Camera/Tween
@onready var ground_check = $GroundCheck @onready var ground_check = $GroundCheck
@onready var climb_tween = $ClimbTween # undergoing redesign in Godot 4 #@onready var climb_tween = $ClimbTween # undergoing redesign in Godot 4
@onready var climb_check = $ClimbCheck #@onready var climb_check = $ClimbCheck
@onready var body = $Body @onready var body = $Body
@onready var mesh = $Mesh @onready var mesh = $Mesh
@ -94,6 +94,10 @@ var jetpack_was_active = false
var velocity := Vector3.ZERO var velocity := Vector3.ZERO
var gravity_vec := Vector3.ZERO var gravity_vec := Vector3.ZERO
var previously_on_floor := false
var lagging_movement_velocity = Vector3.ZERO
var dead = false: # used to workaround Godot crash when destroying player_nodes var dead = false: # used to workaround Godot crash when destroying player_nodes
set(value): set(value):
match value: match value:
@ -101,8 +105,9 @@ var dead = false: # used to workaround Godot crash when destroying player_nodes
#input_active = false #input_active = false
self.hide() self.hide()
$Body.disabled = true $Body.disabled = true
hud.pain = 4 hud.pain = 3
crosshair.hide() crosshair.hide()
#$Head/Camera.transform.origin.y
#set_physics_process(false) #set_physics_process(false)
false: false:
#input_active = true #input_active = true
@ -112,8 +117,10 @@ var dead = false: # used to workaround Godot crash when destroying player_nodes
$SpawnVFX.emitting = true $SpawnVFX.emitting = true
hud.pain = 0 hud.pain = 0
crosshair.show() crosshair.show()
#$Head/Camera.transform.origin = Vector3(0,0,0)
#set_physics_process(true) #set_physics_process(true)
dead = value dead = value
var focus_banner_alpha = 0 var focus_banner_alpha = 0
var focus_banner_inc = 5 var focus_banner_inc = 5
var focus_banner_dec = 1 var focus_banner_dec = 1
@ -143,6 +150,10 @@ func view_banner(show:bool):
@rpc(any_peer, call_local, reliable) func set_dead(is_dead: bool): @rpc(any_peer, call_local, reliable) func set_dead(is_dead: bool):
#print("Recieved RPC call for set_dead ", is_dead) #print("Recieved RPC call for set_dead ", is_dead)
if not is_dead:
spawn()
self.dead = is_dead self.dead = is_dead
# if is_multiplayer_authority(): # if is_multiplayer_authority():
@ -257,8 +268,14 @@ func _input(event) -> void:
func _process(delta): func _process(delta):
if dead: if dead:
# $Head/Camera.position.y = -1 # lower the head to the ground, let the player see their gibs
# $Head/Camera.rotation.x = 0 # reset the tilt so the camera looks forward
# $Head/Camera.rotation.z = -20
return return
# $Head/Camera.position.y = 0
# $Head/Camera.rotation.z = 0
$Jetpack/GPUParticles3D.emitting = jetpack_active $Jetpack/GPUParticles3D.emitting = jetpack_active
if jetpack_active: if jetpack_active:
@ -337,7 +354,11 @@ func _process(delta):
if not dead: if not dead:
rpc(&'moan') # all puppets must scream! rpc(&'moan') # all puppets must scream!
@rpc(any_peer, call_local, reliable) func spawn():
$Head/Camera.position.y = 0
$Head/Camera.rotation.z = 0
jetpack_fuel = jetpack_tank
@rpc(any_peer, call_local, reliable) func die(killer_pid: int): @rpc(any_peer, call_local, reliable) func die(killer_pid: int):
var gibs = gibs_vfx.instantiate() var gibs = gibs_vfx.instantiate()
get_tree().root.add_child(gibs) get_tree().root.add_child(gibs)
@ -358,6 +379,14 @@ func _process(delta):
revenge_pid = killer_pid revenge_pid = killer_pid
$Head/Camera.position.y = -1 # lower the head to the ground, let the player see their gibs
$Head/Camera.rotation.x = 0 # reset the tilt so the camera looks forward
$Head/Camera.rotation.z = -20
jetpack_active = false
view_zoom_target = .0
view_zoom = 0
#queue_free() #queue_free()
func update_player(info) -> void: func update_player(info) -> void:
@ -422,6 +451,25 @@ func _physics_process(delta):
if direction.length() > 0: # normalized() will return a null if direction.length() > 0: # normalized() will return a null
direction = direction.normalized() direction = direction.normalized()
# weapon bob
if direction.length() > 0:
if is_on_floor():
$Head/Camera/Hand/Weapon.transform.origin.y = lerp($Head/Camera/Hand/Weapon.transform.origin.y, sin(main.uptime * 10) / 15, 4 * delta)
else:
$Head/Camera/Hand/Weapon.transform.origin.y *= 1 - delta * 8
$Head/Camera/Hand/Weapon.transform.origin.y += sin(main.uptime * 2) / 1000 * delta
$Head/Camera/Hand/Weapon.transform.origin.y -= motion_velocity.y * delta / 60
if Input.is_action_just_pressed("move_jump") and is_on_floor():
var tween = create_tween()
$Head/Camera/Hand/Weapon.transform.origin.y -= 0.025
#$Head/Camera/Hand/Weapon.transform.origin.y -= 0.05
if is_on_floor() and not previously_on_floor:
$Head/Camera/Hand/Weapon.transform.origin.y -= 1
# if
# $Head/Camera/Hand/Weapon.transform.origin.y -= 0.25
speed = speed_type[medium] speed = speed_type[medium]
accel = accel_type[medium] accel = accel_type[medium]
@ -435,6 +483,10 @@ func _physics_process(delta):
velocity.z = motion_velocity.z velocity.z = motion_velocity.z
gravity_vec.y = motion_velocity.y gravity_vec.y = motion_velocity.y
previously_on_floor = is_on_floor()
lagging_movement_velocity.lerp(motion_velocity, delta)
rpc(&'update_movement', global_transform, head.get_rotation(), motion_velocity, jetpack_active) rpc(&'update_movement', global_transform, head.get_rotation(), motion_velocity, jetpack_active)
# (stair) climbing # (stair) climbing

View File

@ -221,7 +221,6 @@ script = ExtResource( "1" )
[node name="Mesh" type="MeshInstance3D" parent="."] [node name="Mesh" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.852763, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.852763, 0)
layers = 2 layers = 2
cast_shadow = 0
mesh = SubResource( "1" ) mesh = SubResource( "1" )
surface_material_override/0 = null surface_material_override/0 = null
script = null script = null
@ -231,7 +230,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.45276, 0)
script = null script = null
[node name="Camera" type="Camera3D" parent="Head"] [node name="Camera" type="Camera3D" parent="Head"]
transform = Transform3D(1, 0, 2.38419e-07, 0, 1, 0, -2.38419e-07, 0, 1, 0, 0, 0)
fov = 90.0 fov = 90.0
script = null script = null

View File

@ -10,7 +10,6 @@ extends Node3D
func _ready(): func _ready():
$Gibs.emitting = true $Gibs.emitting = true
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta): #func _process(delta):
# pass # pass

View File

@ -18,6 +18,14 @@ emission_sphere_radius = 0.5
spread = 180.0 spread = 180.0
initial_velocity_min = 1.0 initial_velocity_min = 1.0
initial_velocity_max = 8.0 initial_velocity_max = 8.0
angular_velocity_min = -15.0
angular_velocity_max = 15.0
damping_min = 0.1
damping_max = 0.2
angle_min = -180.0
angle_max = 180.0
scale_min = 0.5
scale_max = 3.0
color_ramp = SubResource( "GradientTexture_07eoi" ) color_ramp = SubResource( "GradientTexture_07eoi" )
sub_emitter_mode = 1 sub_emitter_mode = 1
sub_emitter_frequency = 100.0 sub_emitter_frequency = 100.0
@ -25,6 +33,7 @@ sub_emitter_keep_velocity = true
collision_enabled = true collision_enabled = true
collision_friction = 0.31 collision_friction = 0.31
collision_bounce = 0.58 collision_bounce = 0.58
collision_use_scale = true
[sub_resource type="OpenSimplexNoise" id="OpenSimplexNoise_tchuy"] [sub_resource type="OpenSimplexNoise" id="OpenSimplexNoise_tchuy"]
octaves = 2 octaves = 2
@ -82,13 +91,14 @@ script = ExtResource( "1_o0guu" )
[node name="Gibs" type="GPUParticles3D" parent="."] [node name="Gibs" type="GPUParticles3D" parent="."]
layers = 4 layers = 4
emitting = false emitting = false
amount = 128 amount = 32
sub_emitter = NodePath("../Blood") sub_emitter = NodePath("../Blood")
lifetime = 5.0 lifetime = 5.0
one_shot = true one_shot = true
explosiveness = 1.0 explosiveness = 1.0
fixed_fps = 0 fixed_fps = 0
collision_base_size = 0.1 collision_base_size = 0.1
visibility_aabb = AABB(-4, -3.55666, -4, 8, 4.42876, 8)
process_material = SubResource( "ParticlesMaterial_jcugi" ) process_material = SubResource( "ParticlesMaterial_jcugi" )
draw_pass_1 = SubResource( "SphereMesh_ctp33" ) draw_pass_1 = SubResource( "SphereMesh_ctp33" )
script = null script = null

View File

@ -22,7 +22,15 @@ func game_over(winner):
func damage(hp): func damage(hp):
print("HUD damage ", hp) print("HUD damage ", hp)
pain += hp/20 pain += hp/20
func hide():
$Crosshair.hide()
$Chat.hide()
func show():
$Crosshair.show()
$Chat.show()
func update_scoretab(): func update_scoretab():
$ScoreTable/VBoxContainer/ScoreTab.text = '' $ScoreTable/VBoxContainer/ScoreTab.text = ''