@@ -16,18 +16,18 @@ namespace ZO.Sensors {
1616 public class ZOIMU : ZOGameObjectBase , ZOSerializationInterface {
1717
1818 [ Header ( "IMU Parameters" ) ]
19- public bool _flipGravity = false ;
19+ public bool _flipAccelerations = false ;
2020
2121 /// <summary>
22- /// Flips gravity vectory .
22+ /// Flips gravity vector .
2323 /// Why would you: the accelerometer is an intertial sensor and it measures inertial force.
2424 /// The accelerometer doesn’t measure G-force, but rather the force that resists to G.
2525 /// The resisting force aims up to the ceiling.
2626 /// </summary>
2727 /// <value></value>
28- public bool FlipGravity {
29- get { return _flipGravity ; }
30- set { _flipGravity = value ; }
28+ public bool FlipAccellerations {
29+ get { return _flipAccelerations ; }
30+ set { _flipAccelerations = value ; }
3131 }
3232
3333
@@ -116,12 +116,14 @@ protected override async void ZOFixedUpdate() {
116116 _lastVelocity = velocity ;
117117
118118 // apply gravity
119- if ( FlipGravity == true ) {
119+ if ( FlipAccellerations == true ) {
120120 _acceleration += transform . InverseTransformDirection ( UnityEngine . Physics . gravity * - 1 ) ;
121121 } else {
122- _acceleration += transform . InverseTransformDirection ( UnityEngine . Physics . gravity ) ;
122+
123123 }
124-
124+
125+ // calculate gravity
126+ _acceleration += transform . InverseTransformDirection ( UnityEngine . Physics . gravity ) ;
125127 _acceleration = _linearNoise . Apply ( _acceleration ) ;
126128 _acceleration = ZO . Math . ZOMathUtil . lowPassFilter ( _acceleration , prevAcceleration , _preFilterAccelerationAlpha ) ;
127129
@@ -134,6 +136,10 @@ protected override async void ZOFixedUpdate() {
134136 Vector3 publishedAngularVelocity = _angularVelocity ;
135137 Quaternion publishedOrientation = transform . rotation ;
136138
139+ if ( FlipAccellerations == true ) {
140+ publishedAcceleration = publishedAcceleration * - 1 ;
141+ }
142+
137143
138144 if ( OnPublishDelegate != null ) {
139145 await OnPublishDelegate ( this , Name , publishedAcceleration , publishedAngularVelocity , publishedOrientation ) ;
0 commit comments