Repository navigation
Add pet and annoy animations for cats and sheep - #2962
Conversation
|
Test build no longer available. |
|
Hi! 2026-09-24.11-50-17.mp42026-09-24.11-52-06.mp4I would suggest moving |
manuq
left a comment
There was a problem hiding this comment.
Looks good!
In general I'm a bit worried of PetInteraction becoming too complex for the 2 existing scenes using it, the cat and the sheep (well, also a townie in Dev Archipelago!). Maybe we should pause and frame what this node about. A simple "no code" way to react to an interaction?
- Play sound effect.
- Play animation.
- Shake.
- Increment a fact counter.
If you agree, I will document the PetInteaction class with the above. For behaviors that require custom code like the sheep facing away, it would be easier to do them just by connecting to interaction_started of the InteractArea directly.
| if fact_counter: | ||
| fact_counter.increment() | ||
| await sound_effect_player.finished | ||
| if interaction_behavior and interaction_behavior.has_method(&"apply"): |
There was a problem hiding this comment.
Check the function arguments, there is one called _from_right:
func _on_interact_area_interaction_started(player: Player, _from_right: bool) -> void:
You can use it to flip the sprite, instead of calculating it again in apply().
| "texture": SubResource("AtlasTexture_6jekj") | ||
| }], | ||
| "loop": 0, | ||
| "name": &"annoy", |
There was a problem hiding this comment.
For consistency, maybe the animation name should be called "pet" even if we are annoying the sheep. The node name is PetInteraction.
|
|
||
| func apply(player: Player, pet_animation: AnimatedSprite2D) -> void: | ||
| var player_is_on_right := player.global_position.x > pet_animation.global_position.x | ||
| var parent_is_flipped := pet_animation.global_transform.x.x < 0.0 |
There was a problem hiding this comment.
I can see why you added this. Some sheeps are flipped horizontally by scale.x = -1. For example in Fray's End West:
I like that you made this a behavior, although one specific to the sheep. It should go inside a components folder: scenes/game_elements/props/decoration/sheep/components/
Also I find it a bit indirect that InteractArea emits a signal, then PetInteraction captures it and calls apply on this. This behavior could be connected to InteractArea.interaction_started directly. Please do so.
Thanks for your review, @Un-player0 ! Yes, I would say |
|
@MeLoNaCo hi! Are you still around to do the changes suggested above? |
9af47a5 to
f3cd602
Compare
|
I made the changes myself this time. And also:
|
Cats now play a pet animation, while sheep play an annoy animation and turn away from the player.
Adds visual feedback for pet interactions. Make the sound effect also optional. If both are passed, the interact area is disabled until both finish playing. For that, move from using
awaitto use signals with callbacks.Document the PetInteraction class.
Add a configuration warning if the AnimatedSprite2D doesn't have an animation named "pet". Unfortunately this requires making the script a
@tool.Resolves #2220
Co-authored-by: Stephanie Vega tefsv.me@gmail.com