Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the current animation tree and player to AnimationNode #61458

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maiself
Copy link
Contributor

@maiself maiself commented May 27, 2022

Exposes the tree and player members of AnimationNode::State available in C++ to scripts, enabling their use in custom nodes.

Without this various obtuse and potentially problematic workarounds are required.

For example, with this patch, the following code can be changed from this (which has undesired side effects):

# seek the animation to its beginning, which will cause `blend_node` to
# return its length
duration = blend_node(animation_node_name, animation_node, 0.0, true, false,
	0.0, AnimationNode.FILTER_IGNORE, true)

To the more obvious and direct form:

duration = get_player().get_animation(animation_name).length

@maiself maiself requested review from a team as code owners May 27, 2022 07:01
Exposes the `tree` and `player` members of `AnimationNode::State` available
in C++ to scripts, enabling their use in custom nodes.

Without this various obtuse and potentially problematic workarounds
are required.

For example, with this patch, the following code can be changed from
this (which has undesired side effects):

```gdscript
# seek the animation to its beginning, which will cause `blend_node` to
# return its length
duration = blend_node(animation_node_name, animation_node, 0.0, true, false,
	0.0, AnimationNode.FILTER_IGNORE, true)
```

To the more obvious and direct form:

```gdscript
duration = get_player().get_animation(animation_name).length
```
@maiself maiself force-pushed the expose-tree-and-player-to-animation-node branch from bd1c07b to 53930d4 Compare May 27, 2022 08:51
@Calinou Calinou added this to the 4.0 milestone May 27, 2022
@TokageItLab
Copy link
Member

TokageItLab commented May 27, 2022

There is related issue as #23629 (comment); this PR means accessing a scene from a resource, which may cause problems when there are multiple scenes that use the same animation.

@TokageItLab TokageItLab modified the milestones: 4.0, 4.x Aug 29, 2022
@TokageItLab TokageItLab removed this from the 4.x milestone May 29, 2023
@YuriSizov YuriSizov added this to the 4.x milestone May 29, 2023
@YuriSizov
Copy link
Contributor

YuriSizov commented May 29, 2023

Please make a proposal, justifying the need for this feature. Perhaps in a discussion a less problematic implementation can be figured out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants