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
- Mouse input is registered incorrectly in Custom RP when downscaling Render Target and rendering Overlay UI before final upscale
- Time.deltaTime is locked to the display's refresh rate when the built Player is moved to a Secondary Display and Windowed Mode is used
- Crash on RaiseException when importing a specific asset
- Crash on RaiseException when opening a specific project
- DownloadHandlerScript.CompleteContent is called twice when building for WebGL
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.