JointSpring 关节弹簧

struct in UnityEngine

Description 描述

JointSpring is used add a spring force to HingeJoint and PhysicMaterial.

关节弹簧用于给铰链关节和物理材质增加弹力。

JavaScript:

function Start() {

	var hinge = GetComponent.<HingeJoint>();

 

	// Make the spring reach shoot for a 70 degree angle.

	// This could be used to fire off a catapult.

 

	var spring = hinge.spring;

	spring.spring = 10;

	spring.damper = 3;

	spring.targetPosition = 70;

	hinge.spring = spring;

}

C#:

using UnityEngine;

using System.Collections;

 

public class ExampleClass : MonoBehaviour {

    void Start() {

        HingeJoint hinge = GetComponent<HingeJoint>();

        JointSpring spring = hinge.spring;

        spring.spring = 10;

        spring.damper = 3;

        spring.targetPosition = 70;

        hinge.spring = spring;

    }

}

Variables 变量

damperThe damper force uses to dampen the spring.
阻尼器使用阻力抑制弹力。
springThe spring forces used to reach the target position.
该弹簧弹力用于达到目标速度。
targetPositionThe target position the joint attempts to reach.
关节尝试到达的目标位置。