c# - 有没有办法统一更改脚本中 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.
}
}
解决方案
天哪,我感觉自己像个白痴。问题是我在 foreach 循环中使用了“Joint”而不是“CharacterJoint”。这是正确的版本:
void Update()
{
foreach (CharacterJoint jnt in jnts)
{
jnt.swing1Limit
}
}
谢谢您的帮助!
推荐阅读
- python - 将每个索引的编号放在numpy的对应位置
- elasticsearch - 查询多个索引时,仅检索弹性搜索命中中的特定 _index 文档
- java - 使用杰克逊转换带有重复键的 JSON
- wordpress - 如何在使用 WP 加载页面期间阻止外部静态资源
- java - 如何测试 AOP 拦截器?
- c++ - cmake生成的执行文件使用gdb失败
- java - 是否可以让 Maven "WAR" pom.xml 将我的类打包到一个 JAR 中并将 JAR 放在 /WEB-INF/lib 文件夹中?
- c - 如何处理 C 中的未定义行为错误?
- vue.js - 如何在 v-for 循环中跟踪父元素?
- android - 当应用程序进程被杀死时,AlarmManager 不工作