首页 > 解决方案 > 有没有办法统一更改脚本中 CharacterJoint 组件的值(例如 hightwistlimit)?

问题描述

我想在运行时用脚本改变角色关节的各种关节角度。但我没有找到通过脚本访问角度的方法。

我在这里找到了字符关节的脚本 API:https : //docs.unity3d.com/ScriptReference/CharacterJoint.html 但我仍然不确定,例如如何更改特定字符关节的 swingLimit1 值。

我正在使用此代码来调用字符关节的功能,但“jnt”没有任何这些功能。

CharacterJoint[] jnts;

    void Start()
    {
        jnts = GetComponentsInChildren<CharacterJoint>();    
    }

    void Update()
    {
        foreach (Joint jnt in jnts)
        {
            jnt.
        }
    }

标签: c#unity3dphysicsragdoll

解决方案


天哪,我感觉自己像个白痴。问题是我在 foreach 循环中使用了“Joint”而不是“CharacterJoint”。这是正确的版本:

void Update()
    {
        foreach (CharacterJoint jnt in jnts)
        {
            jnt.swing1Limit
        }
    }

谢谢您的帮助!


推荐阅读