findAncestorWorld function Physics
The nearest PhysicsWorld on start or its ancestors, or null.
Implementation
PhysicsWorld? findAncestorWorld(Node start) {
for (Node? current = start; current != null; current = current.parent) {
final world = current.getComponent<PhysicsWorld>();
if (world != null) return world;
}
return null;
}