@@ -7,9 +7,9 @@ namespace ZO {
77 /// <summary>
88 /// Handles all the Unity specific "Character Control" stuff like movement and animation.
99 /// </summary>
10- public class ZOSpotCharacterController : MonoBehaviour {
10+ public class ZOSpotUnityCharacterController : MonoBehaviour {
1111
12- public Rigidbody _rigidBody ;
12+ public Rigidbody _torsoRigidBody ;
1313 public Transform _frontCollider = null ;
1414
1515 public CapsuleCollider FrontColliderCapsule {
@@ -114,25 +114,25 @@ public enum StateEnum {
114114 Error
115115 }
116116
117- public ZOSpotCharacterController . StateEnum State {
117+ public ZOSpotUnityCharacterController . StateEnum State {
118118 get ;
119119 private set ;
120- } = ZOSpotCharacterController . StateEnum . Off ;
120+ } = ZOSpotUnityCharacterController . StateEnum . Off ;
121121
122122 public enum ErrorEnum {
123123 Ok ,
124124 GeneralError ,
125125 ErrorShutdown
126126 }
127127
128- public ZOSpotCharacterController . ErrorEnum Error {
128+ public ZOSpotUnityCharacterController . ErrorEnum Error {
129129 get ;
130130 private set ;
131- } = ZOSpotCharacterController . ErrorEnum . Ok ;
131+ } = ZOSpotUnityCharacterController . ErrorEnum . Ok ;
132132
133133
134134
135- public delegate void SpotControllerStatusDelegate ( ZOSpotCharacterController thisClass , Vector2 linearVelocity , float turnVelocityDegreesPerSecond , float orientationDegrees , ZOSpotCharacterController . StateEnum state , ZOSpotCharacterController . ErrorEnum error ) ;
135+ public delegate void SpotControllerStatusDelegate ( ZOSpotUnityCharacterController thisClass , Vector2 linearVelocity , float turnVelocityDegreesPerSecond , float orientationDegrees , ZOSpotUnityCharacterController . StateEnum state , ZOSpotUnityCharacterController . ErrorEnum error ) ;
136136 private event SpotControllerStatusDelegate _spotControllerStatusDelegate ;
137137 public event SpotControllerStatusDelegate SpotControllerStatus {
138138 add {
@@ -162,22 +162,22 @@ void FixedUpdate() {
162162
163163 if ( IsFrontGrounded || IsRearGrounded ) {
164164
165- Vector3 angularVelocity = _rigidBody . angularVelocity ;
165+ Vector3 angularVelocity = _torsoRigidBody . angularVelocity ;
166166 float torqueYaw = ( _targetTurnVelocityDegreesPerSecond * Mathf . Deg2Rad ) - angularVelocity . y ;
167- _rigidBody . AddRelativeTorque ( new Vector3 ( 0 , torqueYaw , 0 ) , ForceMode . VelocityChange ) ;
167+ _torsoRigidBody . AddRelativeTorque ( new Vector3 ( 0 , torqueYaw , 0 ) , ForceMode . VelocityChange ) ;
168168
169- Vector3 localVelocity = _rigidBody . transform . InverseTransformDirection ( _rigidBody . velocity ) ;
169+ Vector3 localVelocity = _torsoRigidBody . transform . InverseTransformDirection ( _torsoRigidBody . velocity ) ;
170170 Vector3 targetVelocity = new Vector3 ( _targetVelocity . x , 0 , _targetVelocity . y ) ;
171171 Vector3 deltaVelocity = targetVelocity - localVelocity ;
172- deltaVelocity = _rigidBody . transform . TransformDirection ( deltaVelocity ) ;
173- _rigidBody . AddForce ( deltaVelocity , ForceMode . VelocityChange ) ;
172+ deltaVelocity = _torsoRigidBody . transform . TransformDirection ( deltaVelocity ) ;
173+ _torsoRigidBody . AddForce ( deltaVelocity , ForceMode . VelocityChange ) ;
174174
175175
176176 }
177177
178178
179179 if ( _spotControllerStatusDelegate != null ) {
180- _spotControllerStatusDelegate . Invoke ( this , new Vector2 ( _rigidBody . velocity . x , _rigidBody . velocity . z ) , _rigidBody . angularVelocity . y * Mathf . Rad2Deg , transform . rotation . eulerAngles . y , State , Error ) ;
180+ _spotControllerStatusDelegate . Invoke ( this , new Vector2 ( _torsoRigidBody . velocity . x , _torsoRigidBody . velocity . z ) , _torsoRigidBody . angularVelocity . y * Mathf . Rad2Deg , transform . rotation . eulerAngles . y , State , Error ) ;
181181
182182 }
183183
@@ -210,25 +210,25 @@ public void TurnOn() {
210210 }
211211
212212 public void Stand ( ) {
213- if ( State == ZOSpotCharacterController . StateEnum . Sitting ) {
213+ if ( State == ZOSpotUnityCharacterController . StateEnum . Sitting ) {
214214 FrontColliderCapsule . height = FrontColliderCapsule . height * ( 1.0f / _lieDownScale ) ;
215215 RearColliderCapsule . height = RearColliderCapsule . height * ( 1.0f / _lieDownScale ) ;
216- State = ZOSpotCharacterController . StateEnum . UpAndReady ;
216+ State = ZOSpotUnityCharacterController . StateEnum . UpAndReady ;
217217 }
218218 }
219219
220220 public void Sit ( ) {
221- if ( State == ZOSpotCharacterController . StateEnum . UpAndReady || State == ZOSpotCharacterController . StateEnum . Off ) {
221+ if ( State == ZOSpotUnityCharacterController . StateEnum . UpAndReady || State == ZOSpotUnityCharacterController . StateEnum . Off ) {
222222 FrontColliderCapsule . height = FrontColliderCapsule . height * _lieDownScale ;
223223 RearColliderCapsule . height = RearColliderCapsule . height * _lieDownScale ;
224- State = ZOSpotCharacterController . StateEnum . Sitting ;
224+ State = ZOSpotUnityCharacterController . StateEnum . Sitting ;
225225 }
226226
227227 }
228228
229229
230230 public void Move ( Vector2 targetVelocity , float targetTurnVelocityDegreesPerSecond ) {
231- if ( State == ZOSpotCharacterController . StateEnum . UpAndReady ) {
231+ if ( State == ZOSpotUnityCharacterController . StateEnum . UpAndReady ) {
232232 _targetVelocity = targetVelocity ;
233233 _targetTurnVelocityDegreesPerSecond = targetTurnVelocityDegreesPerSecond ;
234234 }
0 commit comments