File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Runtime/Scripts/Sensors/IMU Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -30,13 +30,19 @@ public class IMUSensor : Sensor
30
30
public Vector3 angularVelocity { get => _angularVelocity ; }
31
31
32
32
public Vector3 localVelocity { get => _transform . InverseTransformDirection ( _velocity ) ; }
33
- public Vector3 localAcceleration { get => _transform . InverseTransformDirection ( _acceleration ) ; }
33
+ public Vector3 localAcceleration { get => _transform . InverseTransformDirection ( _acceleration . normalized ) * _acceleration . magnitude ; }
34
34
35
35
private float _dt { get => base . _frequency_inv ; }
36
36
37
+ private Vector3 _gravity ;
38
+ private float _gravityMagnitude ;
39
+
37
40
protected override void Init ( )
38
41
{
39
42
_transform = this . transform ;
43
+
44
+ _gravity = Physics . gravity ;
45
+ _gravityMagnitude = _gravity . magnitude ;
40
46
}
41
47
42
48
protected override void UpdateSensor ( )
@@ -46,7 +52,7 @@ protected override void UpdateSensor()
46
52
47
53
_velocity = ( _position - _position_last ) / _dt ;
48
54
_acceleration = ( _velocity - _velocity_last ) / _dt ;
49
- _acceleration += _transform . InverseTransformVector ( Physics . gravity ) ;
55
+ _acceleration += _transform . InverseTransformVector ( _gravity ) . normalized * _gravityMagnitude ;
50
56
51
57
Quaternion rotation_delta = Quaternion . Inverse ( _rotation_last ) * _rotation ;
52
58
rotation_delta . ToAngleAxis ( out float angle , out Vector3 axis ) ;
Original file line number Diff line number Diff line change @@ -313,6 +313,16 @@ PrefabInstance:
313
313
propertyPath : m_RootOrder
314
314
value : 2
315
315
objectReference : {fileID: 0}
316
+ - target : {fileID: 8550806465241961968, guid: 884f57c81164231419af9316aaca015d,
317
+ type : 3}
318
+ propertyPath : m_LocalScale.y
319
+ value : 1
320
+ objectReference : {fileID: 0}
321
+ - target : {fileID: 8550806465241961968, guid: 884f57c81164231419af9316aaca015d,
322
+ type : 3}
323
+ propertyPath : m_LocalScale.z
324
+ value : 1
325
+ objectReference : {fileID: 0}
316
326
- target : {fileID: 8550806465241961968, guid: 884f57c81164231419af9316aaca015d,
317
327
type : 3}
318
328
propertyPath : m_LocalPosition.x
You can’t perform that action at this time.
0 commit comments