如何在AnimationPlayer中获取动画中的节点?
我试图获取受动画影响的所有节点
我知道可以通过循环轨道找到它们:
for track_indx in animation.get_track_count():
var track_node=get_node(animation.track_get_path(track_indx));
if(!list.has(track_node))
list.append(track_node);
但似乎没有必要为了获取节点而迭代所有轨道,尤其是当有仅一个节点附加了太多轨道。
有更好的方法来实现这一目标吗?
I'm trying to get all the nodes which are effected by an animation
I know that it's possible to find them through looping tracks:
for track_indx in animation.get_track_count():
var track_node=get_node(animation.track_get_path(track_indx));
if(!list.has(track_node))
list.append(track_node);
but it seems unnecessary iterating over all the tracks just to get the nodes, especially when there are too many tracks attached to just one node.
Is there a better way to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有更好的方法了。
我只是想提醒您,轨道的路径是相对于
AnimationPlayer
的root_node
的。您可以通过获取相对于它们的节点并从中使用get_node
来处理相对的 NodePath:There isn't a better way.
I just want to remind you that the paths of tracks are relative to the
root_node
of theAnimationPlayer
. You can deal with relativeNodePath
s by getting the node they are relative to, and usingget_node
from it: