Version: 2017.1

JointMotor

struct in UnityEngine

切换到手册

描述

JointMotor 用于使关节机动化。

例如,可以告知 HingeJoint 采用给定速度和力进行旋转。 关节随后会尝试使用给定的最大力达到相应速度。\ 另请参阅:HingeJoint

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; } }

变量

force电机会施加力。
freeSpin如果启用 /freeSpin/,则电机只加速,不减速。
targetVelocity电机会施加高达 force 的力来实现 /targetVelocity/。