Search Issue Tracker
By Design
Votes
1
Found in
2018.4.0f1
2019.1.0a1
2019.1.2f1
2019.2.0a1
2019.3.0a1
Issue ID
1153873
Regression
No
Mathf.Approximately on similar values do not return true in IL2CPP Standalone
How to reproduce:
1. Open attached project "mathf.approx bug.zip" and scene "Main"
2. Enter Play mode
3. In Game View, press "Begin" button (the "Begin" button changes to "Done", this is expected)
4. Build and Run the standalone with IL2CPP
5. In Standalone, press the "Begin" button
Expected result: the "Begin" button changes to "Done"
Actual result: the "Begin" button is stuck at "Lerping"
Reproducible with: 2018.3.14f1, 2018.4.0f1, 2019.1.3f1, 2019.2.0b2, 2019.3.0a2
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
Resolution Note:
Floating point behavior is different between Mono and IL2CPP. The problem with the example is this line:
f1 = Mathf.Lerp(startValue, endValue, 21.25f * (Time.time - startTime));
"startValue" should be "f1":
f1 = Mathf.Lerp(f1, endValue, 21.25f * (Time.time - startTime));
Without this change the Mathf.Lerp call is always the same and it results in a value that is not quite the same as the end value, probably due to roundoff errors, so the Approximately call will always return false.