godotengine / godotengine/godot
`RayCast3D` cannot detect collision with CSGs in `_ready()` even with `force_raycast_update()`
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
v4.3.stable.mono.official [77dcf97d8]
### System information
Godot v4.3.stable.mono - macOS 14.5.0 - Vulkan (Forward+) - integrated Apple M1 - Apple M1 (8 Threads)
### Issue description
`RayCast3D` cannot properly detect collision with a CSG shape when the collision checking is performed in `_ready()`, even when `force_raycast_update()` is used. Method `is_colliding()` always returns false, despite that "Debug > Visible Collision Shapes" would indicate there is a collision and the same checking performed in `_physics_process()` behaves correctly.
This issue seems similar to [another one previously mentioned](https://github.com/godotengine/godot/issues/95354) but there it was a `RayCast3D` colliding with a `StaticBody3D` and using a `force_raycast_update()` would make it work properly. Here it seems to have no effect.
### Steps to reproduce
1. Make a 3D scene.
2. Add one of the CSG shapes and set `use_collision` to true.
3. Add a `RayCast3D` and position it so that it starts off colliding with the CSG shape.
4. Add a script to the `RayCast3D` to perform some collision checking in `_ready()`. This is what I used:
```gdscript
extends RayCast3D
func _ready() -> void:
force_raycast_update()
print("is_colliding: " + str(is_colliding()))
print("get_collider: " + str(get_collider()))
```
5. Run the game. The script will tell you that no collision is taking place. The output result for the script above is the following:
```
is_colliding: false
get_collider:
```
### Minimal reproduction project (MRP)
[raycast.zip](https://github.com/user-attachments/files/16735530/raycast.zip)
Contributor guide
Research direction
Start with the attached raycast.zip minimal reproduction and the RayCast3D script in the issue. Run the project and compare collision results from _ready() with those from _physics_process(), including the force_raycast_update() call. Done means a RayCast3D initially intersecting a collision-enabled CSG reports the collider when checked in _ready().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100