feat: refine character animation and gameplay UI
This commit is contained in:
parent
63a5009b33
commit
54e1b8538d
14 changed files with 314 additions and 55 deletions
131
player/player.gd
131
player/player.gd
|
|
@ -55,6 +55,14 @@ const CHARACTER_POCKET_IDLE_IDLE_ANIMATION: StringName = &"pocket_idle_idle"
|
|||
const CHARACTER_POCKET_IDLE_SHOW_ANIMATION: StringName = &"pocket_idle_show"
|
||||
const CHARACTER_POCKET_SHOW_SHOW_ANIMATION: StringName = &"pocket_show_show"
|
||||
const CHARACTER_POCKET_SHOW_IDLE_ANIMATION: StringName = &"pocket_show_idle"
|
||||
const CHARACTER_POCKET_SIT_IDLE_IDLE_ANIMATION: StringName = &"pocket_sit_idle_idle"
|
||||
const CHARACTER_POCKET_SIT_IDLE_SHOW_ANIMATION: StringName = &"pocket_sit_idle_show"
|
||||
const CHARACTER_POCKET_SIT_SHOW_SHOW_ANIMATION: StringName = &"pocket_sit_show_show"
|
||||
const CHARACTER_POCKET_SIT_SHOW_IDLE_ANIMATION: StringName = &"pocket_sit_show_idle"
|
||||
const CHARACTER_POCKET_WALKING_IDLE_IDLE_ANIMATION: StringName = &"pocket_walking_idle_idle"
|
||||
const CHARACTER_POCKET_WALKING_IDLE_SHOW_ANIMATION: StringName = &"pocket_walking_idle_show"
|
||||
const CHARACTER_POCKET_WALKING_SHOW_SHOW_ANIMATION: StringName = &"pocket_walking_show_show"
|
||||
const CHARACTER_POCKET_WALKING_SHOW_IDLE_ANIMATION: StringName = &"pocket_walking_show_idle"
|
||||
const CHARACTER_FISHING_ANIMATION: StringName = &"fishing"
|
||||
const CHARACTER_FISHING_SIT_ANIMATION: StringName = &"fishing_sit"
|
||||
const CHARACTER_FIGHTING_ANIMATION: StringName = &"fighting"
|
||||
|
|
@ -239,8 +247,8 @@ class ShowcaseCameraSnapshot:
|
|||
|
||||
@export_category("Movement")
|
||||
@export var walk_speed: float = 2.25
|
||||
@export var sprint_speed: float = 7.2
|
||||
@export var sneak_speed: float = 1.8
|
||||
@export var sprint_speed: float = 4.5
|
||||
@export var sneak_speed: float = 1.125
|
||||
@export var slow_walk_speed: float = 2.9
|
||||
@export_range(0.1, 20.0, 0.1) var jump_velocity: float = 4.6
|
||||
@export_range(0.1, 5.0, 0.05) var upward_gravity_multiplier: float = 1.35
|
||||
|
|
@ -324,6 +332,7 @@ var _free_camera: Camera3D
|
|||
var _free_camera_yaw: float = 0.0
|
||||
var _free_camera_pitch: float = 0.0
|
||||
var _movement_enabled: bool = true
|
||||
var _local_input_suppressors: Dictionary[StringName, bool] = {}
|
||||
var _water_recovery_active: bool = false
|
||||
var _remote_recovery_presentation_active: bool = false
|
||||
var _remote_recovery_visual_origin: Vector3
|
||||
|
|
@ -382,6 +391,8 @@ var _fishing_rod_tip: Marker3D
|
|||
var _active_item_is_rod: bool = false
|
||||
var _controller_mapping_manager: ControllerMappingManagerType
|
||||
|
||||
@onready var _sprint_dust: CPUParticles3D = %SprintDust
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if (
|
||||
|
|
@ -480,7 +491,7 @@ func _physics_process(delta: float) -> void:
|
|||
_network_jump_pending = false
|
||||
return
|
||||
var jump_requested: bool = (
|
||||
_movement_enabled
|
||||
_is_movement_input_enabled()
|
||||
and not _free_camera_active
|
||||
and (
|
||||
(local_control_enabled and Input.is_action_just_pressed("jump"))
|
||||
|
|
@ -513,7 +524,7 @@ func _physics_process(delta: float) -> void:
|
|||
velocity.y = jump_velocity
|
||||
_network_jump_pending = false
|
||||
|
||||
if not _movement_enabled:
|
||||
if not _is_movement_input_enabled():
|
||||
velocity.x = 0.0
|
||||
velocity.z = 0.0
|
||||
move_and_slide()
|
||||
|
|
@ -560,6 +571,7 @@ func _physics_process(delta: float) -> void:
|
|||
|
||||
func _process(delta: float) -> void:
|
||||
_update_character_animation()
|
||||
_update_sprint_dust()
|
||||
# The hand bone supplies the attachment position, but its animated wrist
|
||||
# rotation should not turn the flat fish/catch artwork edge-on. Keep each
|
||||
# display aligned with the character's facing while it follows the hand.
|
||||
|
|
@ -592,7 +604,7 @@ func _process(delta: float) -> void:
|
|||
if _camera_dragging and not Input.is_action_pressed("camera_drag"):
|
||||
_set_camera_dragging(false)
|
||||
|
||||
if _camera_input_enabled:
|
||||
if _is_camera_input_enabled():
|
||||
var stick: Vector2 = _get_controller_camera_stick()
|
||||
if stick.length() > controller_camera_deadzone:
|
||||
if (
|
||||
|
|
@ -624,6 +636,26 @@ func _process(delta: float) -> void:
|
|||
)
|
||||
|
||||
|
||||
func _update_sprint_dust() -> void:
|
||||
if _sprint_dust == null:
|
||||
return
|
||||
var horizontal_speed_squared: float = (
|
||||
velocity.x * velocity.x + velocity.z * velocity.z
|
||||
)
|
||||
var fastest_non_sprint_speed := maxf(
|
||||
walk_speed,
|
||||
maxf(sneak_speed, slow_walk_speed)
|
||||
)
|
||||
var running_threshold := fastest_non_sprint_speed + 0.5
|
||||
_sprint_dust.emitting = (
|
||||
is_on_floor()
|
||||
and not _sitting
|
||||
and not _water_recovery_active
|
||||
and horizontal_speed_squared
|
||||
> running_threshold * running_threshold
|
||||
)
|
||||
|
||||
|
||||
func _get_controller_camera_stick() -> Vector2:
|
||||
if _controller_mapping_manager != null:
|
||||
return Vector2(
|
||||
|
|
@ -819,6 +851,14 @@ func _on_character_animation_finished(animation_name: StringName) -> void:
|
|||
CHARACTER_POCKET_IDLE_SHOW_ANIMATION,
|
||||
CHARACTER_POCKET_SHOW_SHOW_ANIMATION,
|
||||
CHARACTER_POCKET_SHOW_IDLE_ANIMATION,
|
||||
CHARACTER_POCKET_SIT_IDLE_IDLE_ANIMATION,
|
||||
CHARACTER_POCKET_SIT_IDLE_SHOW_ANIMATION,
|
||||
CHARACTER_POCKET_SIT_SHOW_SHOW_ANIMATION,
|
||||
CHARACTER_POCKET_SIT_SHOW_IDLE_ANIMATION,
|
||||
CHARACTER_POCKET_WALKING_IDLE_IDLE_ANIMATION,
|
||||
CHARACTER_POCKET_WALKING_IDLE_SHOW_ANIMATION,
|
||||
CHARACTER_POCKET_WALKING_SHOW_SHOW_ANIMATION,
|
||||
CHARACTER_POCKET_WALKING_SHOW_IDLE_ANIMATION,
|
||||
]:
|
||||
if _pocket_visual_active:
|
||||
_complete_pocket_visual()
|
||||
|
|
@ -904,7 +944,7 @@ func is_sitting() -> bool:
|
|||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if not local_control_enabled or not _camera_input_enabled:
|
||||
if not local_control_enabled or not _is_camera_input_enabled():
|
||||
return
|
||||
if event.is_action_pressed("toggle_free_camera"):
|
||||
_set_free_camera_active(not _free_camera_active)
|
||||
|
|
@ -1056,9 +1096,10 @@ func _update_free_camera_physics() -> void:
|
|||
Input.get_action_strength("jump")
|
||||
- Input.get_action_strength("sneak")
|
||||
)
|
||||
var yaw_basis := Basis(Vector3.UP, _free_camera_yaw)
|
||||
var movement: Vector3 = (
|
||||
_free_camera.global_basis.x * input_vector.x
|
||||
+ _free_camera.global_basis.z * input_vector.y
|
||||
yaw_basis.x * input_vector.x
|
||||
+ yaw_basis.z * input_vector.y
|
||||
+ Vector3.UP * vertical_input
|
||||
)
|
||||
if movement.length_squared() > 1.0:
|
||||
|
|
@ -1077,8 +1118,8 @@ func _rotate_free_camera(delta_rotation: Vector2) -> void:
|
|||
var vertical_direction: float = -1.0 if invert_camera_y else 1.0
|
||||
_free_camera_pitch = clampf(
|
||||
_free_camera_pitch - delta_rotation.y * vertical_direction,
|
||||
deg_to_rad(minimum_pitch_degrees),
|
||||
deg_to_rad(maximum_pitch_degrees),
|
||||
deg_to_rad(-90.0),
|
||||
deg_to_rad(90.0),
|
||||
)
|
||||
_free_camera.global_rotation = Vector3(
|
||||
_free_camera_pitch,
|
||||
|
|
@ -1087,6 +1128,12 @@ func _rotate_free_camera(delta_rotation: Vector2) -> void:
|
|||
)
|
||||
|
||||
|
||||
func get_active_gameplay_camera() -> Camera3D:
|
||||
if _free_camera_active and _free_camera != null:
|
||||
return _free_camera
|
||||
return _camera
|
||||
|
||||
|
||||
func _set_target_zoom(value: float) -> void:
|
||||
_target_zoom = clampf(value, minimum_zoom, maximum_zoom)
|
||||
|
||||
|
|
@ -1132,7 +1179,11 @@ func configure_network_remote(authoritative_simulation: bool) -> void:
|
|||
func capture_network_input(sequence: int) -> Dictionary:
|
||||
if _sitting_intent_pending and _sitting_intent_sequence < 0:
|
||||
_sitting_intent_sequence = sequence
|
||||
if not _movement_enabled or _water_recovery_active or _free_camera_active:
|
||||
if (
|
||||
not _is_movement_input_enabled()
|
||||
or _water_recovery_active
|
||||
or _free_camera_active
|
||||
):
|
||||
return {
|
||||
"sequence": sequence,
|
||||
"axis": [0.0, 0.0],
|
||||
|
|
@ -1363,6 +1414,26 @@ func is_movement_enabled() -> bool:
|
|||
return _movement_enabled
|
||||
|
||||
|
||||
func set_local_input_suppressed(owner: StringName, suppressed: bool) -> void:
|
||||
if owner.is_empty():
|
||||
return
|
||||
if suppressed:
|
||||
_local_input_suppressors[owner] = true
|
||||
velocity.x = 0.0
|
||||
velocity.z = 0.0
|
||||
_set_camera_dragging(false)
|
||||
else:
|
||||
_local_input_suppressors.erase(owner)
|
||||
|
||||
|
||||
func _is_movement_input_enabled() -> bool:
|
||||
return _movement_enabled and _local_input_suppressors.is_empty()
|
||||
|
||||
|
||||
func _is_camera_input_enabled() -> bool:
|
||||
return _camera_input_enabled and _local_input_suppressors.is_empty()
|
||||
|
||||
|
||||
func set_camera_input_enabled(enabled: bool) -> void:
|
||||
_camera_input_enabled = enabled
|
||||
if not enabled:
|
||||
|
|
@ -1642,7 +1713,33 @@ func _begin_pocket_visual(
|
|||
midpoint_callback: Callable = Callable(),
|
||||
) -> void:
|
||||
var animation_name: StringName
|
||||
if starts_in_show_pose:
|
||||
if _sitting:
|
||||
if starts_in_show_pose:
|
||||
animation_name = (
|
||||
CHARACTER_POCKET_SIT_SHOW_SHOW_ANIMATION
|
||||
if ends_in_show_pose
|
||||
else CHARACTER_POCKET_SIT_SHOW_IDLE_ANIMATION
|
||||
)
|
||||
else:
|
||||
animation_name = (
|
||||
CHARACTER_POCKET_SIT_IDLE_SHOW_ANIMATION
|
||||
if ends_in_show_pose
|
||||
else CHARACTER_POCKET_SIT_IDLE_IDLE_ANIMATION
|
||||
)
|
||||
elif _is_moving_for_pocket_visual():
|
||||
if starts_in_show_pose:
|
||||
animation_name = (
|
||||
CHARACTER_POCKET_WALKING_SHOW_SHOW_ANIMATION
|
||||
if ends_in_show_pose
|
||||
else CHARACTER_POCKET_WALKING_SHOW_IDLE_ANIMATION
|
||||
)
|
||||
else:
|
||||
animation_name = (
|
||||
CHARACTER_POCKET_WALKING_IDLE_SHOW_ANIMATION
|
||||
if ends_in_show_pose
|
||||
else CHARACTER_POCKET_WALKING_IDLE_IDLE_ANIMATION
|
||||
)
|
||||
elif starts_in_show_pose:
|
||||
animation_name = (
|
||||
CHARACTER_POCKET_SHOW_SHOW_ANIMATION
|
||||
if ends_in_show_pose
|
||||
|
|
@ -1665,8 +1762,7 @@ func _begin_pocket_visual(
|
|||
else:
|
||||
_cancel_pocket_visual()
|
||||
if (
|
||||
_sitting
|
||||
or animation_name.is_empty()
|
||||
animation_name.is_empty()
|
||||
or _character_animation_player == null
|
||||
or not _character_animation_player.has_animation(animation_name)
|
||||
):
|
||||
|
|
@ -1689,6 +1785,11 @@ func _begin_pocket_visual(
|
|||
_schedule_pocket_visual_midpoint(midpoint_generation, animation_name)
|
||||
|
||||
|
||||
func _is_moving_for_pocket_visual() -> bool:
|
||||
var horizontal_velocity := Vector2(velocity.x, velocity.z)
|
||||
return horizontal_velocity.length_squared() > 0.0025
|
||||
|
||||
|
||||
func _schedule_pocket_visual_midpoint(
|
||||
generation: int,
|
||||
animation_name: StringName,
|
||||
|
|
@ -1758,6 +1859,7 @@ func begin_catch_showcase(fish_catch: FishCatchType) -> void:
|
|||
if _pocket_visual_target == PocketVisualTarget.CATCH_SHOWCASE:
|
||||
_cancel_pocket_visual()
|
||||
_showcase_animation_active = true
|
||||
set_fishing_visual(false)
|
||||
_kill_showcase_camera_tween()
|
||||
_kill_showcase_restore_tween()
|
||||
_capture_showcase_camera_snapshot()
|
||||
|
|
@ -1785,6 +1887,7 @@ func begin_remote_catch_showcase(fish_catch: FishCatchType) -> void:
|
|||
return
|
||||
end_catch_showcase(Callable(), true)
|
||||
_showcase_animation_active = true
|
||||
set_fishing_visual(false)
|
||||
_showcase_rod_visibility = _fishing_rod.visible
|
||||
_showcase_rod_state_stored = true
|
||||
_fishing_rod.visible = false
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=18 format=3]
|
||||
[gd_scene load_steps=21 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://player/player.gd" id="1_script"]
|
||||
[ext_resource type="Script" path="res://inventory/fish_inventory.gd" id="2_inventory"]
|
||||
|
|
@ -24,6 +24,17 @@ height = 1.8
|
|||
material = ExtResource("12_blob_shadow")
|
||||
size = Vector2(1.15, 0.72)
|
||||
|
||||
[sub_resource type="Shader" id="SprintDustShader"]
|
||||
code = "shader_type spatial;\nrender_mode blend_mix, depth_draw_never, cull_disabled, unshaded, shadows_disabled;\n\nuniform vec4 dust_color : source_color = vec4(0.47, 0.39, 0.27, 0.42);\nvarying float particle_phase;\n\nvoid vertex() {\n\tparticle_phase = INSTANCE_CUSTOM.y;\n\tMODELVIEW_MATRIX = VIEW_MATRIX * mat4(\n\t\tINV_VIEW_MATRIX[0],\n\t\tINV_VIEW_MATRIX[1],\n\t\tINV_VIEW_MATRIX[2],\n\t\tMODEL_MATRIX[3]\n\t);\n}\n\nvoid fragment() {\n\tvec2 centered_uv = UV * 2.0 - 1.0;\n\tfloat angle = atan(centered_uv.y, centered_uv.x);\n\tfloat edge_wobble = sin(angle * 5.0 + particle_phase * 8.0) * 0.07;\n\tfloat radius = length(centered_uv);\n\tfloat soft_shape = 1.0 - smoothstep(0.48 + edge_wobble, 1.0 + edge_wobble, radius);\n\tfloat fade_in = smoothstep(0.0, 0.12, particle_phase);\n\tfloat fade_out = 1.0 - smoothstep(0.38, 1.0, particle_phase);\n\tALBEDO = dust_color.rgb;\n\tALPHA = soft_shape * dust_color.a * fade_in * fade_out;\n}\n"
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="SprintDustMaterial"]
|
||||
render_priority = 1
|
||||
shader = SubResource("SprintDustShader")
|
||||
|
||||
[sub_resource type="QuadMesh" id="SprintDustMesh"]
|
||||
material = SubResource("SprintDustMaterial")
|
||||
size = Vector2(0.38, 0.28)
|
||||
|
||||
[node name="Player" type="CharacterBody3D"]
|
||||
collision_layer = 2
|
||||
collision_mask = 1
|
||||
|
|
@ -55,6 +66,28 @@ rotation_degrees = Vector3(-90, 0, 0)
|
|||
cast_shadow = 0
|
||||
mesh = SubResource("GroundShadowMesh")
|
||||
|
||||
[node name="SprintDust" type="CPUParticles3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
position = Vector3(0, 0.08, 0)
|
||||
emitting = false
|
||||
amount = 16
|
||||
lifetime = 0.65
|
||||
randomness = 0.55
|
||||
visibility_aabb = AABB(-4, -2, -4, 8, 5, 8)
|
||||
local_coords = false
|
||||
emission_shape = 3
|
||||
emission_box_extents = Vector3(0.24, 0.03, 0.16)
|
||||
direction = Vector3(0, 1, 0)
|
||||
spread = 65.0
|
||||
gravity = Vector3(0, -0.8, 0)
|
||||
initial_velocity_min = 0.35
|
||||
initial_velocity_max = 0.8
|
||||
angular_velocity_min = -90.0
|
||||
angular_velocity_max = 90.0
|
||||
scale_amount_min = 0.35
|
||||
scale_amount_max = 0.72
|
||||
mesh = SubResource("SprintDustMesh")
|
||||
|
||||
[node name="CharacterRig" parent="Visuals" instance=ExtResource("13_character")]
|
||||
rotation_degrees = Vector3(0, 180, 0)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue