您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
39 行
1.0 KiB
39 行
1.0 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ApplyCoriolisCentrifugal : MonoBehaviour
|
|
{
|
|
public bool applyForce = false;
|
|
private ArticulationBody[] abs;
|
|
void Start()
|
|
{
|
|
abs = FindObjectsOfType<ArticulationBody>();
|
|
}
|
|
|
|
|
|
void FixedUpdate()
|
|
{
|
|
if (!applyForce)
|
|
{
|
|
for (int i = 0; i < abs.Length; i++)
|
|
{
|
|
abs[i].jointForce = new ArticulationReducedSpace(0);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
List<float> results = new List<float>();
|
|
List<int> indices = new List<int>();
|
|
|
|
abs[0].GetJointCoriolisCentrifugalForces(results);
|
|
abs[0].GetDofStartIndices(indices);
|
|
|
|
for (int i = 0; i < abs.Length; i++)
|
|
{
|
|
// Since all joints in this articulation only have 1 DoF we can get away with writing it like this
|
|
abs[i].jointForce = new ArticulationReducedSpace(results[indices[abs[i].index]]);
|
|
}
|
|
}
|
|
}
|