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
Comments (1)
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
- Test Runner’s vertical scrollbar overlaps with the up and down arrows and upper toolbar tabs when the window is minimized
- The Input Field view is not updated when deleting lines of text
- The scrollbar does not respect empty lines in the Input Field
- “Texture Atlas Viewer“ button text overlaps another button when the UI Toolkit Debugger is narrowed
- Thresholds are no longer automatically calculated after deleting Motion fields in Blendtrees
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