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
- A new Additive Scene cannot be created when an empty Untitled Scene is not dirty
- [Scene View][Ubuntu] Prefab mode UI ghosting in HDRP
- Deleting AudioMixer asset throws MissingReferenceException and breaks the Audio Mixer window
- Crash on ScheduleGenerateTilingShape when modifying PolygonCollider2D path count and setting path vertices
- Crash when a scene is created with LocalPhysicsMode::Physics3D
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