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
- “[Worker0] Could not generate preview image“ error when opening macOS native plugin in the Inspector with Architecture to build for set to ARM 64-bit
- [iOS] Application.absoluteURL is empty on Awake/Start when opening via deep link with Splash Screen disabled
- Crash on MemoryManager::Deallocate when rapidly calling Addressables.LoadAssetAsync
- Crash on physx::shdfnd::atomicIncrement when adjusting values on a character controller component after entering Play mode in Prefab edit mode
- [Rendering Debugger] [NewInputSystem] Debug Overlays in Play mode throws InvalidOperationException when using New Input System
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.