Do not assume class of first node in group player#2369
Open
manuq wants to merge 2 commits into
Open
Conversation
Input HUD: It considers the player a CharacterBody2D and checks for its components using `Object.get(COMPONENT_NAME) as COMPONENT_CLASS`. Previously it was assuming that the output of `get_first_node_in_group()` was a CharacterBody2D. The assignment would fail if the first node in group "player" is of another type. This doesn't allow mock players, for example an AnimatedSprite2D in a cinematic. Throwing enemy: All this enemy needs is the global_position of player for throwing. This makes it closer to the ThrowProjectileBehavior which has `@export var target: Node2D`. Also get the player node from group "player" only once. player_follower.gd: All this script needs is the global_position of player for calculating the offset.
|
Play this branch at https://play.threadbare.game/branches/endlessm/improve-getting-player-node/. (This launches the game from the start, not directly at the change(s) in this pull request.) |
Collaborator
Author
|
I only made the change in Renya intro for testing. But if we agree on this solution, at least for the existing cinematics, then I can update them all. Link to watch the test scene: |
This makes the dialogue balloon to appear at the top of the screen when the sprite is at the bottom. Fix #2306
dc85a76 to
fa79280
Compare
Collaborator
Author
|
I updated all the cinematic scenes now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So cinematics can assign "player" group to the mock player sprite.
This makes the dialogue balloon to appear at the top of the screen when the
sprite is at the bottom.
Do not assume class of first node in group player
Certain scripts could treat player as a CharacterBody2D for physics,
as a Node2D for its position, or as a CanvasItem for visual stuff, etc.
Input HUD: It considers the player a CharacterBody2D and checks for its
components using
Object.get(COMPONENT_NAME) as COMPONENT_CLASS. Previously itwas assuming that the output of
get_first_node_in_group()was aCharacterBody2D. The assignment would fail if the first node in group "player"
is of another type. This doesn't allow mock players, for example an
AnimatedSprite2D in a cinematic.
Throwing enemy: All this enemy needs is the global_position of player for
throwing. This makes it closer to the ThrowProjectileBehavior which has
@export var target: Node2D. Also get the player node from group "player" only once.player_follower.gd: All this script needs is the global_position of player
for calculating the offset.
Fix #2306