Search Issue Tracker
By Design
Votes
0
Found in
2019.4
2020.3
2020.3.12f1
2021.1
2021.2
2022.1
Issue ID
1360314
Regression
No
RaycastAll returns 0 hits when Raycasting to a GameObject immediately after changing the GameObject's Position
How to reproduce:
1. Open the attached project "RaycastAll"
2. Open the scene "TestScene" and enter Play mode (Assets/Scenes/TestScene.unity)
3. In the Game view, press the spacebar key
4. Observe the Console window (Window > General > Console)
Expected result: RaycastAll returns 1 hit for each "Unit" GameObject
Actual result: RaycastAll returns 0 hits for each "Unit" GameObject
Reproducible with: 2019.4.30f1, 2020.3.18f1, 2021.1.22f1, 2021.2.0b12, 2022.1.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:
After changing the transform, PhysX needs to be informed, so it could change the physics bodies as well. This would be done automatically in the next frame. If you do your raycast on the same frame as you changed the Unity transform, the PhysX body will not have updated yet and you will not hit your raycast. If you need to Raycast it on the same frame, you should call Physics.SyncTransforms() before raycasting.