Search Issue Tracker
Fixed in 4.6.1
Votes
1
Found in
4.6.0b17
Issue ID
636745
Regression
No
RaycastHit2D.distance shows wrong value when using Vector2.up
To reproduce this bug:
1. Open the attached project
2. Open 'RaycastHit2D' scene
3. It has a 'RayOrigin' object which casts ray and 2 box colliders, one in the right side and one above
4. Press play
5. In the console, RaycastHit2D.distance is printed
6. When the ray is cast to Vector.right direction, the result is correct
7. When the ray is cast to Vector.up direction, the result is incorrect
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
ironicnet
Oct 04, 2014 17:07
I can reproduce this using this piece of code:
RaycastHit2D groundTest = Physics2D.Raycast(transform.position, new Vector2(0, -1), 5, CollidingMask);
Debug.Log(string.Format("Hit.Distance: {0}", groundTest.distance));
Debug.Log(string.Format("Vector2.Distance: {0}", Vector2.Distance(new Vector2(transform.position.x, transform.position.y),groundTest.point)));
Debug.Log(string.Format("Magnitude: {0}", (new Vector2(transform.position.x, transform.position.y)- groundTest.point).magnitude));
The output is for example:
Hit.Distance: 4.352383
Vector2.Distance: 0.6476175
Magnitude: 0.6476175