3d homing rocket without hitting walls

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By RonHabaron

im trying to make a “homing rocket” in my 3d game, i want the homing rocket to not hit any objects and fly to the enemy even if he is 1000 pixels above the ground, but I couldnt find a way to do it with navigation node because it only allows the rocket to fly on a singel y axis while i want it to be able to fly anywhere around the world without hitting walls.
any suggestions?

Much depends on how sparse your world is - if it’s not a maze, you could cast a few rays in front of the rocket and change direction if there’s a wall.

If it’s more complicated, a tutorial for full path finding solution in 3d space might just be out of scope for q&a site :smiley:

aXu_AP | 2022-09-18 15:13

My map is gonna be too complicated for raycasts but thanks anyways for the suggestion.
I searched all over YouTube and Google but couldn’t find single solution that fits, everything was with only one y layer, which is good for enemy running towards you, but for a homing missile it’s not.

RonHabaron | 2022-09-19 11:30

:bust_in_silhouette: Reply From: aXu_AP

Thankfully, most pathfinding algorithms should be possible to implement in higher dimensions. Many of them work on node structure, which is agnostic to actual geometry.

Harder problem might be generating the dataset needed, unless your world happens to be voxel based (3d grid). You could try casting cube shapes via intersect_shape (docs) at points of a rectangular grid to make a voxel representation of places rocket can or cannot go. Run astar or similiar algorithm then on this data. Performance/quality adjustments come from the fidelity of the voxel grid.