Description
The TargetAngle
property of the HingeJoint
class specifies the desired angle that the motor should aim to achieve. This property is part of the motor settings group and is used to control the rotational position of the hinge joint when the motor is active.
Usage
To use the TargetAngle
property, ensure that the motor mode is enabled on the HingeJoint
. You can set this property to define the angle in degrees that the motor should target. This is particularly useful for simulating mechanical systems like doors or wheels that need to rotate to a specific position.
Example
// Example of setting the TargetAngle for a HingeJoint
HingeJoint hingeJoint = new HingeJoint();
// Enable motor mode
hingeJoint.Motor = HingeJoint.MotorMode.Enabled;
// Set the target angle to 90 degrees
hingeJoint.TargetAngle = 90.0f;
// Optionally, configure other motor properties
hingeJoint.MaxTorque = 10.0f;
hingeJoint.TargetVelocity = 5.0f;