Add ambient character blinking

This commit is contained in:
Alexander Sellite 2026-08-11 16:39:20 -04:00
parent c038eeadea
commit e791f15e87
3 changed files with 76 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View file

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b2ufsni8mnpmq"
path="res://.godot/imported/eyes_closed.png-80789498475c2cfbcb6e3ac14e067a76.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://art/exported/characters/faces/eyes/eyes_closed.png"
dest_files=["res://.godot/imported/eyes_closed.png-80789498475c2cfbcb6e3ac14e067a76.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -84,6 +84,9 @@ enum PocketVisualTarget {
CATCH_SHOWCASE,
}
const FIGHTING_EYES_ID: String = "alligator_eyes"
const BLINK_EYES_ID: String = "closed"
const BLINK_INTERVAL_SECONDS := Vector2(2.8, 7.5)
const BLINK_DURATION_SECONDS: float = 0.11
const CHARACTER_CALL_MOUTH_ID: String = "open_ah"
const CHARACTER_CALL_MOUTH_DURATION_SECONDS: float = 0.16
const BASE_REEL_SPEED: float = 0.16
@ -155,6 +158,9 @@ func set_fighting_visual(active: bool) -> void:
if _fighting_visual_active == active:
return
_fighting_visual_active = active
if active:
_blink_visual_active = false
_schedule_next_blink()
_apply_presented_appearance()
_character_animation_name = &""
_update_character_animation()
@ -236,6 +242,9 @@ func _apply_presented_appearance() -> void:
if not is_node_ready() or _visuals == null:
return
var presented_appearance := appearance_snapshot
if _blink_visual_active and not _fighting_visual_active:
presented_appearance = appearance_snapshot.duplicate(true)
presented_appearance["eyes"] = BLINK_EYES_ID
if _fighting_visual_active:
presented_appearance = appearance_snapshot.duplicate(true)
presented_appearance["eyes"] = FIGHTING_EYES_ID
@ -402,6 +411,9 @@ var _pocket_visual_midpoint_callback: Callable
var _pocket_visual_midpoint_called: bool = false
var _pocket_visual_generation: int = 0
var _fighting_visual_active: bool = false
var _blink_visual_active: bool = false
var _blink_seconds_remaining: float = 0.0
var _blink_rng := RandomNumberGenerator.new()
var _character_call_mouth_active: bool = false
var _character_call_visual_generation: int = 0
var _fishing_visual_active: bool = false
@ -417,6 +429,8 @@ var _controller_mapping_manager: ControllerMappingManagerType
func _ready() -> void:
_blink_rng.randomize()
_schedule_next_blink()
if (
_character_animation_player != null
and not _character_animation_player.animation_finished.is_connected(
@ -592,6 +606,7 @@ func _physics_process(delta: float) -> void:
func _process(delta: float) -> void:
_update_blink(delta)
_update_character_animation()
_update_sprint_dust()
# The hand bone supplies the attachment position, but its animated wrist
@ -658,6 +673,27 @@ func _process(delta: float) -> void:
)
func _update_blink(delta: float) -> void:
if _fighting_visual_active:
return
_blink_seconds_remaining -= delta
if _blink_seconds_remaining > 0.0:
return
_blink_visual_active = not _blink_visual_active
if _blink_visual_active:
_blink_seconds_remaining = BLINK_DURATION_SECONDS
else:
_schedule_next_blink()
_apply_presented_appearance()
func _schedule_next_blink() -> void:
_blink_seconds_remaining = _blink_rng.randf_range(
BLINK_INTERVAL_SECONDS.x,
BLINK_INTERVAL_SECONDS.y,
)
func _update_sprint_dust() -> void:
if _sprint_dust == null:
return