Reimplemented bullet hit effects in the new damage system.
parent
35253ee7e1
commit
29bf99d59e
|
@ -1,5 +1,7 @@
|
|||
extends CharacterBody3D
|
||||
|
||||
var impact_player = preload("res://Assets/Effects/ImpactBlood.tscn")
|
||||
|
||||
var max_health = 100
|
||||
var health = max_health:
|
||||
set(value):
|
||||
|
@ -352,6 +354,12 @@ func _process(delta):
|
|||
if not dead:
|
||||
rpc(&'moan') # all puppets must scream!
|
||||
|
||||
# spawn the bullet hit effect
|
||||
var impact_vfx = impact_player.instantiate()
|
||||
impact_vfx.global_transform = impact_vfx.global_transform.looking_at(hit_normal)
|
||||
impact_vfx.global_transform.origin = hit_position
|
||||
get_tree().root.add_child(impact_vfx)
|
||||
|
||||
@rpc(any_peer, call_local, reliable) func spawn(spawn_transform: Transform3D):
|
||||
dead = false
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ var casing = preload("res://Assets/Weapons/Handgun/Casing.tscn")
|
|||
var flash = preload("res://Assets/Effects/MuzzleFlash.tscn")
|
||||
var tracer = preload("res://Assets/Effects/BulletTracer.tscn")
|
||||
var impact_wall = preload("res://Assets/Effects/ImpactSparks.tscn")
|
||||
var impact_player = preload("res://Assets/Effects/ImpactBlood.tscn")
|
||||
|
||||
|
||||
# accuracy
|
||||
var spread_min = 1
|
||||
|
@ -66,6 +66,8 @@ var spread = spread_min
|
|||
|
||||
return # skip the rest - it's deprecated code
|
||||
|
||||
####################### DEPRACATED ↓↓↓↓↓↓↓↓
|
||||
|
||||
var impact_vfx
|
||||
|
||||
if ray: # did we hit anything?
|
||||
|
@ -107,22 +109,29 @@ var spread = spread_min
|
|||
main.rpc(&'player_list_update', main.player_list.get(ray['collider'].get_multiplayer_authority()).serialize(), ray['collider'].get_multiplayer_authority())
|
||||
main.update_hud()
|
||||
|
||||
impact_vfx = impact_player.instantiate()
|
||||
# impact_vfx = impact_player.instantiate()
|
||||
else:
|
||||
impact_vfx = impact_wall.instantiate()
|
||||
|
||||
if impact_vfx != null:
|
||||
impact_vfx.global_transform = impact_vfx.global_transform.looking_at(ray['normal'])
|
||||
impact_vfx.global_transform.origin = ray['position']
|
||||
get_tree().root.add_child(impact_vfx)
|
||||
# impact_vfx = impact_wall.instantiate()
|
||||
pass
|
||||
|
||||
# if impact_vfx != null:
|
||||
# impact_vfx.global_transform = impact_vfx.global_transform.looking_at(ray['normal'])
|
||||
# impact_vfx.global_transform.origin = ray['position']
|
||||
# get_tree().root.add_child(impact_vfx)
|
||||
#
|
||||
#print(ray)
|
||||
|
||||
####################### DEPRACATED ↑↑↑↑↑↑↑↑
|
||||
|
||||
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', 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
|
||||
# TODO take data from the material of the target and spawn an appropriate hit effect
|
||||
var impact_vfx = impact_wall.instantiate()
|
||||
impact_vfx.global_transform = impact_vfx.global_transform.looking_at(hit_normal)
|
||||
impact_vfx.global_transform.origin = hit_position
|
||||
get_tree().root.add_child(impact_vfx)
|
||||
|
||||
func trigger(index: int, active: bool) -> void:
|
||||
#print("Weapon " + str(name) + ", Trigger " + str(index) + ", active: " + str(active))
|
||||
|
@ -141,5 +150,7 @@ func trigger(index: int, active: bool) -> void:
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
|
||||
|
||||
# align the sound source with the head to produce balanced stereo
|
||||
pass #$SFX/Shoot.global_transform = camera.global_transform
|
||||
|
|
Reference in New Issue