Refine character animation and fishing presentation
This commit is contained in:
parent
81f5010ad2
commit
c596b2aee7
15 changed files with 403 additions and 402 deletions
|
|
@ -18,6 +18,10 @@ const PlayerCoolerCapacityType = preload(
|
|||
"res://progression/player_cooler_capacity.gd"
|
||||
)
|
||||
|
||||
const CHARACTER_IDLE_ANIMATION: StringName = &"idle"
|
||||
const CHARACTER_WALKING_ANIMATION: StringName = &"walking"
|
||||
const CHARACTER_SITTING_ANIMATION: StringName = &"sitting"
|
||||
|
||||
var appearance_snapshot: Dictionary = (
|
||||
CharacterCustomizationCatalog.default_snapshot()
|
||||
)
|
||||
|
|
@ -81,6 +85,9 @@ class ShowcaseCameraSnapshot:
|
|||
@export var zoom_smoothing: float = 12.0
|
||||
|
||||
@onready var _visuals: Node3D = %Visuals
|
||||
@onready var _character_animation_player: AnimationPlayer = (
|
||||
get_node_or_null("Visuals/CharacterRig/AnimationPlayer") as AnimationPlayer
|
||||
)
|
||||
@onready var _camera_yaw: Node3D = %CameraYaw
|
||||
@onready var _camera_pitch: Node3D = %CameraPitch
|
||||
@onready var _spring_arm: SpringArm3D = %SpringArm3D
|
||||
|
|
@ -133,6 +140,8 @@ var _network_target_position: Vector3
|
|||
var _network_target_velocity: Vector3
|
||||
var _network_target_visual_yaw: float = 0.0
|
||||
var _network_snapshot_ready: bool = false
|
||||
var _character_animation_name: StringName = &""
|
||||
var _sitting: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -145,6 +154,9 @@ func _physics_process(delta: float) -> void:
|
|||
if _network_interpolation_enabled:
|
||||
_update_network_interpolation(delta)
|
||||
return
|
||||
if _sitting:
|
||||
velocity = Vector3.ZERO
|
||||
return
|
||||
if _water_recovery_active:
|
||||
velocity = Vector3.ZERO
|
||||
return
|
||||
|
|
@ -215,6 +227,7 @@ func _physics_process(delta: float) -> void:
|
|||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
_update_character_animation()
|
||||
if _remote_recovery_presentation_active:
|
||||
_remote_recovery_elapsed += delta
|
||||
_visuals.position = (
|
||||
|
|
@ -258,6 +271,48 @@ func _process(delta: float) -> void:
|
|||
)
|
||||
|
||||
|
||||
func _update_character_animation() -> void:
|
||||
if _character_animation_player == null:
|
||||
return
|
||||
var horizontal_speed_squared: float = (
|
||||
velocity.x * velocity.x + velocity.z * velocity.z
|
||||
)
|
||||
var next_animation: StringName = (
|
||||
CHARACTER_SITTING_ANIMATION
|
||||
if _sitting
|
||||
else (
|
||||
CHARACTER_WALKING_ANIMATION
|
||||
if horizontal_speed_squared > 0.0025
|
||||
else CHARACTER_IDLE_ANIMATION
|
||||
)
|
||||
)
|
||||
if not _character_animation_player.has_animation(next_animation):
|
||||
return
|
||||
if _character_animation_name == next_animation:
|
||||
return
|
||||
_character_animation_player.play(next_animation)
|
||||
_character_animation_name = next_animation
|
||||
|
||||
|
||||
func toggle_sitting() -> void:
|
||||
if (
|
||||
_character_animation_player == null
|
||||
or not _character_animation_player.has_animation(
|
||||
CHARACTER_SITTING_ANIMATION
|
||||
)
|
||||
):
|
||||
return
|
||||
_sitting = not _sitting
|
||||
if _sitting:
|
||||
velocity = Vector3.ZERO
|
||||
_character_animation_name = &""
|
||||
_update_character_animation()
|
||||
|
||||
|
||||
func is_sitting() -> bool:
|
||||
return _sitting
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if not local_control_enabled or not _camera_input_enabled:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -63,21 +63,24 @@ cast_shadow = 0
|
|||
mesh = SubResource("GroundShadowMesh")
|
||||
|
||||
[node name="CharacterRig" parent="Visuals" instance=ExtResource("13_character")]
|
||||
rotation_degrees = Vector3(0, 180, 0)
|
||||
|
||||
[node name="AnimationPlayer" parent="Visuals/CharacterRig"]
|
||||
autoplay = "idle"
|
||||
|
||||
[node name="FishingRod" type="Node3D" parent="Visuals"]
|
||||
unique_name_in_owner = true
|
||||
position = Vector3(0.16, 0.38, 0.02)
|
||||
rotation = Vector3(-0.785398, 0, 0)
|
||||
[node name="FishingRodAttachment" type="BoneAttachment3D" parent="Visuals/CharacterRig/CharacterRig/Skeleton3D"]
|
||||
bone_name = "hand.R"
|
||||
|
||||
[node name="RodMesh" type="MeshInstance3D" parent="Visuals/FishingRod"]
|
||||
[node name="FishingRod" type="Node3D" parent="Visuals/CharacterRig/CharacterRig/Skeleton3D/FishingRodAttachment"]
|
||||
unique_name_in_owner = true
|
||||
rotation = Vector3(-0.785398, -0.007863, 3.141593)
|
||||
|
||||
[node name="RodMesh" type="MeshInstance3D" parent="Visuals/CharacterRig/CharacterRig/Skeleton3D/FishingRodAttachment/FishingRod"]
|
||||
position = Vector3(0, 0.42, 0)
|
||||
mesh = SubResource("FishingRodMesh")
|
||||
material_override = SubResource("FishingRodMaterial")
|
||||
|
||||
[node name="FishingRodTip" type="Marker3D" parent="Visuals/FishingRod"]
|
||||
[node name="FishingRodTip" type="Marker3D" parent="Visuals/CharacterRig/CharacterRig/Skeleton3D/FishingRodAttachment/FishingRod"]
|
||||
unique_name_in_owner = true
|
||||
position = Vector3(0, 0.95, 0)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,25 @@ const PlayerScene: PackedScene = preload("res://player/player.tscn")
|
|||
static func instantiate_visuals() -> Node3D:
|
||||
var source: Player = PlayerScene.instantiate()
|
||||
var visuals := source.get_node("Visuals") as Node3D
|
||||
var source_rod_attachment: Node = visuals.find_child(
|
||||
"FishingRodAttachment", true, false
|
||||
)
|
||||
var source_rod_parent: Node = null
|
||||
var source_rod_index: int = -1
|
||||
if source_rod_attachment != null:
|
||||
source_rod_parent = source_rod_attachment.get_parent()
|
||||
source_rod_index = source_rod_attachment.get_index()
|
||||
source_rod_attachment.owner = null
|
||||
source_rod_parent.remove_child(source_rod_attachment)
|
||||
var presentation := visuals.duplicate(
|
||||
Node.DUPLICATE_SIGNALS
|
||||
| Node.DUPLICATE_GROUPS
|
||||
| Node.DUPLICATE_SCRIPTS
|
||||
| Node.DUPLICATE_USE_INSTANTIATION
|
||||
) as Node3D
|
||||
if source_rod_attachment != null and source_rod_parent != null:
|
||||
source_rod_parent.add_child(source_rod_attachment)
|
||||
source_rod_parent.move_child(source_rod_attachment, source_rod_index)
|
||||
source.free()
|
||||
presentation.name = "PlayerVisuals"
|
||||
return presentation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue