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
- ZivaRT Player and ML Agents packages Deprecated label color differs from other Deprecated packages
- Description, Version History, Dependencies and Samples paragraph/items distance from borders differ in Package Manager
- "Clear Filters" button has a blue "on-click" highlight
- All other Package Manager filter options are hidden when "Update Available" option is selected and "Filters" tab is reopened
- Crash on RaiseException when generating lighting in a specific project
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