用户工具

站点工具


侧边栏



Unity3D中文文档

script:unityengine:classes:jointmotor:jointmotor

JointMotor 关节马达

struct in UnityEngine

Description 描述

The JointMotor is used to motorize a joint.

该关节马达用于关节的机动。

For example the HingeJoint can be told to rotate at a given speed and force. The joint will then attempt to reach the velocity with the given maximum force.

例如:铰链关节可以被指定的速度和力旋转。该关节将会尝试达到指定最大力的速度。

JavaScript:

function Start() {
	var hinge = GetComponent.<HingeJoint>();
 
	// Make the hinge motor rotate with 90 degrees per second and a strong force.
	var motor = hinge.motor;
	motor.force = 100;
	motor.targetVelocity = 90;
	motor.freeSpin = false;
	hinge.motor = motor;
}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    void Start() {
        HingeJoint hinge = GetComponent<HingeJoint>();
        JointMotor motor = hinge.motor;
        motor.force = 100;
        motor.targetVelocity = 90;
        motor.freeSpin = false;
        hinge.motor = motor;
    }
}

Variables 变量

forceThe motor will apply a force.
该马达将会施加一个力。
freeSpinIf freeSpin is enabled the motor will only accelerate but never slow down.
如果启用了freeSpin,那么马达将会仅加速而不会减速。
targetVelocityThe motor will apply a force up to force to achieve targetVelocity.
该马达将会施加一个力以达到指定目标速度。
script/unityengine/classes/jointmotor/jointmotor.txt · 最后更改: 2016/08/02 05:32 (外部编辑)