InteractiveCloth.AttachToCollider 附加碰撞器

function AttachToCollider (collider : Collider, tearable : bool = false, twoWayInteraction : bool = false) : void

Description描述

Attaches a collider to the cloth object.

附加一个碰撞器到布料物体。

Only has an effect if some vertices of the cloth are intersecting the collider. These vertices will then become static in their position with respect to the collider. If tearable is true, attachments can tear of, depending on the value of attachmentTearFactor. If twoWayInteraction is true, the cloth will apply forces back to the attached rigidbody, depending on the value of attachmentResponse.

只影响,如果布料是交互碰撞器的某些顶点。这些顶点就会成为静态,在它们碰撞器的位置。如果撕裂为true,附加的可以被撕裂,取决于attachmentTearFactor的值。如果twoWayInteraction为true,布料将应用力返回到附加的刚体,取决于attachmentResponse的值。

参见:DetachFromCollider函数

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public InteractiveCloth cloth;
	void Start() {
		if (cloth)
			cloth.AttachToCollider(transform.collider, true, true);
		else
			Debug.LogError("No cloth was assigned in the inspector");
	}
}
// Attach this transform's collider to a cloth, make
// it tearable and two way interactive on forces.
// REMEMBER: Only has an effect if some vertices of
// the cloth are intersecting the collider
//附加这个变换的碰撞器到一个布料,使它可撕裂和双向互动
//注意:只影响,如果布料是交互碰撞器的某些顶点。

var cloth : InteractiveCloth;

function Start() {
	if(cloth)
		cloth.AttachToCollider(transform.collider, true, true);
	else
		Debug.LogError("No cloth was assigned in the inspector");
}
最后修改:2011年3月27日 Sunday 19:16

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。