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
- Render Graph Execution errors when using GPU occlusion culling with 'Opaque Objects' frame setting disabled on a Camera
- Animator window: “Delete” menu item not greyed out for Base Layer context menu
- Resetting “PC_RP Asset (Universal Render Pipeline Asset)” causes Game view to become black and throws Renderer and NullReference errors in the Console window
- [Mobile] Player Crash on scripting_invoke_profiler_begin when the built Player Scene has an empty UIDocument and is built on IL2CPP
- Unnecessary Warnings are logged when running Player with -batchmode -nographics
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.