Skip to content

Commit 3fef9ce

Browse files
committed
added joint motor access
1 parent 7f8dd12 commit 3fef9ce

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Runtime/Scripts/Physics/ZOHingeJoint.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public class ZOHingeJoint : MonoBehaviour, ZOSerializationInterface, ZOJointInte
2727
public Rigidbody _connectedBody;
2828
public Vector3 _anchor = Vector3.zero;
2929
public Vector3 _axis = Vector3.forward;
30+
public bool _useMotor = true;
31+
public float _motorForce = 1.0f;
3032

3133
[SerializeField] [ZOReadOnlyAttribute] public UnityEngine.HingeJoint _hingeJoint;
3234

@@ -40,6 +42,34 @@ public UnityEngine.HingeJoint UnityHingeJoint {
4042
}
4143
}
4244

45+
/// <summary>
46+
/// Flag to indicate if using joint motor or freewheeling.
47+
/// </summary>
48+
/// <value></value>
49+
public bool UseMotor {
50+
get {
51+
return UnityHingeJoint.useMotor;
52+
}
53+
set {
54+
UnityHingeJoint.useMotor = value;
55+
}
56+
}
57+
58+
/// <summary>
59+
/// The maximum force the motor uses.
60+
/// </summary>
61+
/// <value></value>
62+
public float MotorForce {
63+
get {
64+
return UnityHingeJoint.motor.force;
65+
}
66+
set {
67+
JointMotor jointMotor = UnityHingeJoint.motor;
68+
jointMotor.force = value;
69+
UnityHingeJoint.motor = jointMotor;
70+
}
71+
}
72+
4373
/// <summary>
4474
/// The direction of axis in which the body is constrained.
4575
/// </summary>
@@ -229,6 +259,8 @@ private void OnValidate() {
229259
Axis = _axis;
230260
ConnectedBody = _connectedBody;
231261
Anchor = _anchor;
262+
UseMotor = _useMotor;
263+
MotorForce = _motorForce;
232264
}
233265

234266
#endregion

0 commit comments

Comments
 (0)