# How do I calculate path to intercept a moving object?

Attention Topic was automatically imported from the old Question2Answer platform.

I am trying to understand a simple concept to decide if a given project is viable or not, and I’ve hit a situation in which my math - non existent - abilities are giving me a big problem.

Here is a image of the problem:

• objA’s objective is to intercept objB in it’s orbit around objC using constant speed.
• objB follows an orbital path in constant speed and maintaining the same distance to objC.
• objC is stationary and serves only as to point the center of objB’s rotation.

How do I calculate the path in which objA has to travel in order for it to intercept objB in it’s orbit without changing its speed nor direction midflight?

Have you tried about using a `Kinematicbody2D` node and the test_move() function?

I’ve read the `test_move()` function. As I understood it, it checks if there’s going to be a collision in a given location. The problem with this approach is that it would always return false, because the objcB is constantly moving.

As I see it, calculating the correct location in the future where objcB will be located and when objA will be able to meet it.

Somar | 2021-03-15 01:49

I will attempt to make one of the solutions in Godot and comment if it works out

I used a binary search to calculate the trajectory of the ship. Here is the GitHub repo link.

Interesting. I’ll do some research on binary search. There seems to be a bug on the demo though, the ship always misses the planet on the upper right side of the screen.

Somar | 2021-03-16 19:03

Yeah, I guess the search is not accurate enough. I will see if I can improve it.

exuin | 2021-03-16 19:04