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
- Fixing Message Loss in UMPE During Domain Reload
- The Editor freezes when ScheduleReadOnly of IJobParallelForTransform with dependency is used
- Text is truncated in the Inspector when the display scale is set to 150%
- CancellationTokenSource(<timeout>) has incorrect cancellation status when used in WebGL Player
- VFX property value names are cut off when properties with 'Arc' are viewed in the VFX Blackboard
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.