【问题标题】:Setting one animation key also sets another设置一个动画键也会设置另一个
【发布时间】:2022-10-14 15:00:25
【问题描述】:

我有一个自定义属性,当我添加它的动画键时,我还希望自动添加其他动画键

例如如果我按Cusotm Btn 动画键,它应该也会自动按下PositionRotation Degrees

这样的事情可能吗?
(理想情况下不必篡改AnimationPlayerAnimation 节点?)

【问题讨论】:

  • Animation 混在一起正是我想到的。您可以在Animation 中查找更改并在适当时添加额外的曲目。
  • @Theraot 那是我的计划,但我很好奇,以防我错过了我本可以使用的其他东西,但如果没有,我会发布我自己的答案

标签: animation godot gdscript


【解决方案1】:

没办法,只好做个自定义动画播放器

tool
extends Animation
class_name CustomAnimation


func track_insert_key(track_idx : int, time : float, key, transition : float = 1) -> void:
    .track_insert_key(track_idx, time, key, transition)
    
    var local_node=self.get_local_scene()
    var track_path=track_get_path(track_idx)
    
    var key_node=local_node.get_node(track_path)
    if(key_node.get_class()=="custom_node"):
        var property=track_path.get_subname(0)
        if(property=="custom_prop"):
            remove_track(track_idx)
            var position_track_path=String(track_path).split(":")[0]+":position"
            var position_track_idx=find_track(NodePath(position_track_path))
    
            if(position_track_idx==-1):# if position track does not exist
                position_track_idx=add_track(0)
                track_set_path(position_track_idx,position_track_path)

            track_insert_key(position_track_idx,time,key_node.position)
            
            #do the same for rotation_degrees
            ...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-17
    • 1970-01-01
    • 2015-03-27
    • 1970-01-01
    • 2012-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多