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
- Bad performance when executing the Physics.IgnoreCollisions() method while in Play Mode
- Sprite Editor has a thicker separator between buttons when "Sprite Editor" option is selected
- "NullReferenceException: Object reference not set to an instance of an object" error is thrown when UpdateVolumeStack function is called
- [Windows] Unicode custom text input window shows question marks when inserting an emoji
- Memory leak when the VFX Graph Editor is open
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