尝试将实例化游戏对象克隆的球体碰撞器附加到衣服上,以便它们在运行时都碰撞。
目前,我已经标记了所有克隆,并希望创建新的ClothSphereColliderPair。到目前为止,这是我的服装脚本:
public class ClothTest : MonoBehaviour
{
GameObject[] colliderSpheres;
// Start is called before the first frame update
void Start()
{
colliderSpheres = GameObject.FindGameObjectsWithTag("Hand");
Cloth a = GetComponent<Cloth>();
foreach (Object player in colliderSpheres) {
var ClothColliders = new ClothSphereColliderPair[3];
ClothColliders[0] = new ClothSphereColliderPair(GameObject.FindWithTag("Hand").GetComponent<SphereCollider>());
a.sphereColliders = ClothColliders;
}
}
// Update is called once per frame
void Update()
{
}
}
将仅填充一个对撞机。我还测试了同一个游戏对象的副本(未生成),并且只有一个填充了布料Sphere Collider字段。感谢您的帮助:)