我有一个攻击动画,我想获取攻击动画里面”武器“骨骼的世界位置以匹配碰撞,我该使用什么方法获取骨骼的世界位置?
在Godot代码中获取某一骨骼的世界位置
在Godot中使用Spine时,你可以通过SpineSprite
节点来获取骨骼的世界位置。具体来说,你可以使用get_global_bone_transform(name)
方法来获取骨骼在Godot画布空间中的变换。以下是一个示例代码:
# 假设你有一个SpineSprite节点
var spine_sprite = $SpineSprite
# 获取"weapon"骨骼的世界变换
var weapon_transform = spine_sprite.get_global_bone_transform("weapon")
# 从变换中提取位置
var weapon_position = weapon_transform.origin
通过这种方式,你可以获取到"weapon"骨骼的世界位置,并使用它来匹配碰撞检测。
Wutong Spinebot's answer is correct.
Here is a link to the section in the documentation that explains this, just in case: spine-godot 运行时文档 #获取和设置骨骼变换
感谢你,我的朋友,祝你度过愉快的一天!