45. Physics, areas and ray queries
func make_blocker() -> StaticBody3D:
var body := StaticBody3D.new()
var collision := CollisionShape3D.new()
var box := BoxShape3D.new()
box.size = Vector3.ONE
collision.shape = box
body.add_child(collision)
return bodyfunc run() -> String:
var body: StaticBody3D = make_blocker()
var result: String = body.get_class()
body.free()
return resultGodot physics needs CollisionObject/PhysicsBody/Area nodes, shapes and matching collision layers/masks. A visible mesh alone is not a collision body. Perform physics-space queries at the appropriate physics stage, and defer collision changes when a physics callback requires it.
A ray query uses PhysicsRayQueryParameters3D and the active World3D’s direct_space_state.intersect_ray. Camera screen coordinates must belong to that camera’s viewport. PCA can render a room into an internal viewport; raw window coordinates are not automatically correct.
PCA navigation obstacles, hotspot picking and event volumes are not automatically identical to Godot physics bodies. Use PCA trigger events for normal adventure actors unless your extension has supplied/tested real physics bodies for that interaction.
