mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-01-20 03:54:47 +00:00
Merge branch 'cleanup/use-death-animation' into 'develop'
✨ Use death animation rather than tween, saves network packets! See merge request open-fpsz/open-fpsz!20
This commit is contained in:
commit
d8f14a5852
|
|
@ -31,7 +31,7 @@ var gravity : Vector3 = g * ProjectSettings.get_setting("physics/3d/default_gra
|
|||
@onready var hud = $HUD
|
||||
@onready var shape_cast = $ShapeCast3D
|
||||
@onready var weapon = $SpringArm3D/Inventory/SpaceGun
|
||||
@onready var weapon_animations : AnimationPlayer = $WeaponAnimations
|
||||
@onready var animation_player : AnimationPlayer = $AnimationPlayer
|
||||
|
||||
@onready var spring_arm_height = $SpringArm3D.position.y
|
||||
|
||||
|
|
@ -62,8 +62,8 @@ func _fire_primary():
|
|||
weapon.transform = _original_weapon_transform
|
||||
weapon.fire_primary()
|
||||
weapon.transform = current_weapon_transform
|
||||
weapon_animations.stop()
|
||||
weapon_animations.play("shoot")
|
||||
animation_player.stop()
|
||||
animation_player.play("shoot")
|
||||
|
||||
func _jump():
|
||||
if player_state == PlayerState.PLAYER_DEAD:
|
||||
|
|
@ -94,10 +94,10 @@ func _process(delta):
|
|||
return
|
||||
%SpringArm3D.global_transform.basis = Basis.from_euler(Vector3(input.camera_rotation.y, input.camera_rotation.x, 0.0))
|
||||
|
||||
if weapon_animations.current_animation == "shoot":
|
||||
if animation_player.current_animation == "shoot":
|
||||
pass
|
||||
else:
|
||||
weapon_animations.play("idle")
|
||||
animation_player.play("idle")
|
||||
|
||||
func _physics_process(delta):
|
||||
if player_state == PlayerState.PLAYER_DEAD:
|
||||
|
|
@ -138,15 +138,14 @@ func _physics_process(delta):
|
|||
|
||||
func _die():
|
||||
player_state = PlayerState.PLAYER_DEAD
|
||||
animation_player.stop()
|
||||
animation_player.play("death")
|
||||
var tween = create_tween()
|
||||
tween.tween_property(input, "camera_rotation:y", -PI/2, 0.25)
|
||||
tween.tween_property($SpringArm3D, "position:y", -0.75, 0.25)
|
||||
tween.tween_interval(2)
|
||||
tween.tween_callback(func(): died.emit(self))
|
||||
tween.tween_callback(func(): animation_player.stop())
|
||||
|
||||
func respawn(location):
|
||||
$SpringArm3D.position.y = spring_arm_height
|
||||
input.camera_rotation.y = 0
|
||||
linear_velocity = Vector3()
|
||||
$HealthComponent.heal_full()
|
||||
position = location
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=16 format=3 uid="uid://cbhx1xme0sb7k"]
|
||||
[gd_scene load_steps=17 format=3 uid="uid://cbhx1xme0sb7k"]
|
||||
|
||||
[ext_resource type="Script" path="res://characters/player/player.gd" id="1_ymjub"]
|
||||
[ext_resource type="PackedScene" uid="uid://bcv81ku26xo" path="res://interfaces/hud/hud.tscn" id="2_5qvi2"]
|
||||
|
|
@ -18,40 +18,6 @@ absorbent = true
|
|||
material = SubResource("StandardMaterial3D_1hdqa")
|
||||
radius = 0.25
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_rqdp6"]
|
||||
properties/0/path = NodePath(".:linear_velocity")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 1
|
||||
properties/1/path = NodePath(".:position")
|
||||
properties/1/spawn = true
|
||||
properties/1/replication_mode = 1
|
||||
properties/2/path = NodePath(".:player_id")
|
||||
properties/2/spawn = true
|
||||
properties/2/replication_mode = 2
|
||||
properties/3/path = NodePath("HealthComponent:health")
|
||||
properties/3/spawn = true
|
||||
properties/3/replication_mode = 2
|
||||
properties/4/path = NodePath(".:player_state")
|
||||
properties/4/spawn = true
|
||||
properties/4/replication_mode = 2
|
||||
properties/5/path = NodePath("SpringArm3D:position")
|
||||
properties/5/spawn = true
|
||||
properties/5/replication_mode = 2
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_5j4ew"]
|
||||
properties/0/path = NodePath(".:direction")
|
||||
properties/0/spawn = false
|
||||
properties/0/replication_mode = 1
|
||||
properties/1/path = NodePath(".:jetting")
|
||||
properties/1/spawn = false
|
||||
properties/1/replication_mode = 2
|
||||
properties/2/path = NodePath(".:camera_rotation")
|
||||
properties/2/spawn = false
|
||||
properties/2/replication_mode = 1
|
||||
properties/3/path = NodePath(".:skiing")
|
||||
properties/3/spawn = false
|
||||
properties/3/replication_mode = 2
|
||||
|
||||
[sub_resource type="Animation" id="Animation_cb46l"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
|
|
@ -78,6 +44,30 @@ tracks/1/keys = {
|
|||
"update": 0,
|
||||
"values": [Vector3(0, 3.14159, 0)]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("SpringArm3D:position")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 0.5, 0)]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/path = NodePath("SpringArm3D:rotation")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_as2v0"]
|
||||
resource_name = "idle"
|
||||
|
|
@ -135,13 +125,72 @@ tracks/1/keys = {
|
|||
"values": [Vector3(-0.0584511, 3.14159, 8.83593e-09), Vector3(0, 3.14159, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_yqgrk"]
|
||||
resource_name = "death"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("SpringArm3D:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 0.5, 0), Vector3(0, -0.114794, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("SpringArm3D:rotation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 0, 0), Vector3(-1.35254, 0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_hg307"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_cb46l"),
|
||||
"death": SubResource("Animation_yqgrk"),
|
||||
"idle": SubResource("Animation_as2v0"),
|
||||
"shoot": SubResource("Animation_p84l0")
|
||||
}
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_rqdp6"]
|
||||
properties/0/path = NodePath(".:linear_velocity")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 1
|
||||
properties/1/path = NodePath(".:position")
|
||||
properties/1/spawn = true
|
||||
properties/1/replication_mode = 1
|
||||
properties/2/path = NodePath(".:player_id")
|
||||
properties/2/spawn = true
|
||||
properties/2/replication_mode = 2
|
||||
properties/3/path = NodePath("HealthComponent:health")
|
||||
properties/3/spawn = true
|
||||
properties/3/replication_mode = 2
|
||||
properties/4/path = NodePath(".:player_state")
|
||||
properties/4/spawn = true
|
||||
properties/4/replication_mode = 2
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_5j4ew"]
|
||||
properties/0/path = NodePath(".:direction")
|
||||
properties/0/spawn = false
|
||||
properties/0/replication_mode = 1
|
||||
properties/1/path = NodePath(".:jetting")
|
||||
properties/1/spawn = false
|
||||
properties/1/replication_mode = 2
|
||||
properties/2/path = NodePath(".:camera_rotation")
|
||||
properties/2/spawn = false
|
||||
properties/2/replication_mode = 1
|
||||
properties/3/path = NodePath(".:skiing")
|
||||
properties/3/spawn = false
|
||||
properties/3/replication_mode = 2
|
||||
|
||||
[node name="Player" type="RigidBody3D"]
|
||||
axis_lock_angular_x = true
|
||||
axis_lock_angular_y = true
|
||||
|
|
@ -181,6 +230,13 @@ transform = Transform3D(-1, 0, 2.53518e-06, 0, 1, 0, -2.53518e-06, 0, -1, 0.2446
|
|||
|
||||
[node name="HealthComponent" parent="." instance=ExtResource("5_dlsxj")]
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_hg307")
|
||||
}
|
||||
autoplay = "idle"
|
||||
playback_default_blend_time = 0.05
|
||||
|
||||
[node name="ServerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_rqdp6")
|
||||
|
||||
|
|
@ -188,10 +244,3 @@ replication_config = SubResource("SceneReplicationConfig_rqdp6")
|
|||
root_path = NodePath(".")
|
||||
replication_config = SubResource("SceneReplicationConfig_5j4ew")
|
||||
script = ExtResource("6_xwlxv")
|
||||
|
||||
[node name="WeaponAnimations" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_hg307")
|
||||
}
|
||||
autoplay = "idle"
|
||||
playback_default_blend_time = 0.05
|
||||
|
|
|
|||
Loading…
Reference in a new issue