本文整理汇总了C#中BodyPart.AddRigidbody方法的典型用法代码示例。如果您正苦于以下问题:C# BodyPart.AddRigidbody方法的具体用法?C# BodyPart.AddRigidbody怎么用?C# BodyPart.AddRigidbody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BodyPart
的用法示例。
在下文中一共展示了BodyPart.AddRigidbody方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConnectTo
/*
* Create a configurable joint on this BodyPart connected to target applying resistance back to the previous pose
* NOTE: If maxforce is 0, the ragdoll will crumple like a chump
* */
public ConfigurableJoint ConnectTo(BodyPart target, float resistance, float maxForce)
{
// store the current rotation and enter initialRotation to create the joint
Quaternion q = bone.localRotation;
bone.localRotation = _initialRotation;
// ensure there is a rigidbody
AddRigidbody();
rigidbody.isKinematic = true;
// create the new joint and configure it
joint = gameObject.AddComponent<ConfigurableJoint>();
joint.connectedBody = target.AddRigidbody(); // NOTE: this function takes care of validation internally
joint.axis = jointAxis;
joint.secondaryAxis = jointSecondaryAxis;
joint.xMotion =
joint.yMotion =
joint.zMotion = ConfigurableJointMotion.Locked;
joint.angularXMotion =
joint.angularYMotion =
joint.angularZMotion = ConfigurableJointMotion.Limited;
SoftJointLimit limit = new SoftJointLimit();
limit.limit = xMin;
joint.lowAngularXLimit = limit;
limit.limit = xMax;
joint.highAngularXLimit = limit;
limit.limit = yMax;
joint.angularYLimit = limit;
limit.limit = zMax;
joint.angularZLimit = limit;
joint.rotationDriveMode = RotationDriveMode.Slerp;
JointDrive drive = new JointDrive();
drive.mode = JointDriveMode.Position;
drive.positionSpring = resistance;
drive.maximumForce = maxForce;
joint.slerpDrive = drive;
joint.targetRotation = q*Quaternion.Inverse(initialRotation);
// disable world-space configuration to ensure settings are applied
joint.configuredInWorldSpace = false;
// return to the current orientation
bone.localRotation = q;
rigidbody.isKinematic = false;
return joint;
}