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
- Shader Graph Asset icon is not shown on creation unless you confirm the name
- APV Sky occlusion doesn't consider the terrain
- [iOS] "EXC_BAD_ACCESS" Player crash when Script Debugging is enabled
- Cursor skips input fields when tabbing between two sets of input fields
- "Shader error redefinition of 'Varyings'" error appears when selecting the shader
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.