当前位置: 首页>>代码示例>>C#>>正文


C# BodyPart.AddRigidbody方法代码示例

本文整理汇总了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;
	}
开发者ID:hyper-active,项目名称:virtual-reality,代码行数:51,代码来源:BodyPart.cs


注:本文中的BodyPart.AddRigidbody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。