JointMotor

struct in UnityEngine

Switch to Manual

Description

JointMotor 用于使关节机动化。

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.
See Also: HingeJoint.

using UnityEngine;

public class Example : MonoBehaviour { void Start() { HingeJoint hinge = GetComponent<HingeJoint>();

// Make the hinge motor rotate with 90 degrees per second and a strong force. JointMotor motor = hinge.motor; motor.force = 100; motor.targetVelocity = 90; motor.freeSpin = false; hinge.motor = motor; } }

Variables

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