0 votes

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:
The image depicts three objects, object A, a spaceship in the middle left of the image, object B a planet and object C a star in the middle of the image. A red line is drawn around object C to serve as path to object B.

  • 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?

Godot version v3.2.3-stable-win64
in Engine by (24 points)

3 Answers

+2 votes
Best answer

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

by (7,190 points)
selected by

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.

enter image description here

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

0 votes

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

by (2,080 points)

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.

0 votes


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

by (7,190 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.