File tree 1 file changed +5
-3
lines changed
Assets/UnitySensors/Runtime/Scripts/Sensors/IMU
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -48,24 +48,26 @@ protected override void Init()
48
48
_gravityMagnitude = Physics . gravity . magnitude ;
49
49
}
50
50
51
- private void FixedUpdate ( )
51
+ protected override void Update ( )
52
52
{
53
- float dt = Time . fixedDeltaTime ;
53
+ float dt = Time . deltaTime ;
54
54
55
55
_position_tmp = _transform . position ;
56
56
_velocity_tmp = ( _position_tmp - _position_last ) / dt ;
57
57
_acceleration_tmp = ( _velocity_tmp - _velocity_last ) / dt ;
58
58
_acceleration_tmp -= _transform . InverseTransformDirection ( _gravityDirection ) * _gravityMagnitude ;
59
59
60
60
_rotation_tmp = _transform . rotation ;
61
- Quaternion rotation_delta = Quaternion . Inverse ( _rotation_last ) * _rotation ;
61
+ Quaternion rotation_delta = Quaternion . Inverse ( _rotation_last ) * _rotation_tmp ;
62
62
rotation_delta . ToAngleAxis ( out float angle , out Vector3 axis ) ;
63
63
float angularSpeed = ( angle * Mathf . Deg2Rad ) / dt ;
64
64
_angularVelocity_tmp = axis * angularSpeed ;
65
65
66
66
_position_last = _position_tmp ;
67
67
_velocity_last = _velocity_tmp ;
68
68
_rotation_last = _rotation_tmp ;
69
+
70
+ base . Update ( ) ;
69
71
}
70
72
71
73
protected override void UpdateSensor ( )
You can’t perform that action at this time.
0 commit comments