Search Issue Tracker
By Design
Votes
0
Found in
2018.4
2019.4
2019.4.11f1
2020.2
2020.3
2021.1
2021.2
Issue ID
1312802
Regression
No
Physics2D - CircleCast hit point is different than Raycast from the same origin point
Reproduction steps:
1. Open user's project "circlecast_issue.zip"
2. Open "SampleScene" Scene
3. Enter Play Mode
4. Press the space bar
5. Observe the Console
Expected result: CircleCast hit point has the same coordinates as Raycast hit point
Actual result: CircleCast registers collision with the Box Collider 2D 0.0025 points nearer than Raycast does (4.9975 and 5)
Reproducible with: 2018.4.32f1, 2019.4.22f1, 2020.2.7f1, 2020.3.0f1, 2021.1.0b10, 2021.2.0a8
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
Resolution Note:
Raycasts are not used by the physics system at all, only by end users and are a pure geometric intersection test. All other queries such as shape overlap/casts use functions that the physics system uses and so give results based upon where they would actually contact which isn't idential to a real intersection. This takes into account things like the contact offset etc. (https://docs.unity3d.com/ScriptReference/Physics2D-defaultContactOffset.html).
A raycast will give you the exact point of intersection but there are no cases in physics where a point moves through the world i.e. there's no point collider.
If the user wants to know where a circle would then they can move back by the radius of the circle but the physics system would also move it further back by the contact offset.
In short:
Raycast = Utility Intersection Test no used by physics so doesn't produce real contacts, just intersection
Shape Overlap/Cast = Real physics contact intersection tests.