HingeJoint.spring 弹簧

var spring : JointSpring

Description描述

The spring attempts to reach a target angle by adding spring and damping forces.

通过添加弹簧和阻尼力,弹簧试图达到一个目标角度。

The spring.spring force attempts to reach the target angle. A larger value makes the spring reach the target position faster.

spring.spring力试图达到目标角度,一个较大的值是弹簧达到目标位置较快。

The spring.damper force dampens the angular velocity. A larger value makes the spring reach the goal slower.

spring.damper力阻尼角速度,一个较大的值使弹簧到达目的变慢。

The spring reaches for the spring.targetPosition angle in degrees relative to the rest angle. The rest angle between the bodies is always zero at the beginning of the simulation.

弹簧到达目标位置spring.targetPosition角度相对于静止角度,两个刚体之间的静止角度在模拟开始时总是零。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public void Awake() {
		hingeJoint.spring.spring = 10;
		hingeJoint.spring.damper = 3;
		hingeJoint.spring.targetPosition = 70;
	}
}
// Make the spring reach shoot for a 70 degree angle.
// This could be used to fire off a catapult.
//使弹簧尽量到达70度角
//这可以用来发射弹弓

hingeJoint.spring.spring = 10;
hingeJoint.spring.damper = 3;
hingeJoint.spring.targetPosition = 70;

Modifying the spring automatically enables it.

通过设置HingeJoint.useSpring为true,修改弹簧为自动。

最后修改:2011年1月28日 Friday 15:18

本脚本参考基于Unity 3.4.1f5

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