motor
The motor will apply a force up to a maximum force to achieve the target velocity in degrees per second.
Read time 1 minuteLast updated 7 days ago
Definition
- Type: Property
- Namespace: UnityEngine
- Assembly: UnityEngine.PhysicsModule
public JointMotor motor { get; set; }
Remarks
The motor tries to reach _targetVelocity angular velocity in degrees per second. The motor will only be able to reach , if _force is sufficiently large. If the joint is spinning faster than the motor will brake. A negative will make the motor spin in the opposite direction.
targetVelocitytargetVelocitytargetVelocityThe is the maximum torque the motor can exert. If it is zero the motor is disabled.
forceThe motor will brake when it is spinning faster than only, if _freeSpin is false. If is true the motor will not brake.
targetVelocityfreeSpinModifying the motor does not automatically enable the motor.
Enabling the motor overrides the _spring, given the spring was enabled. If the motor is again disabled the spring will be restored.
Additional Resources: _useMotor, JointMotor
Examples
using UnityEngine;public class Example : MonoBehaviour{ void 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; hinge.useMotor = true; }}