0 votes

I want my spaceship to be forced into a circular orbit when it enters an Area2D with point gravity. I am new to Godot so I'm not quite sure what I'm doing, but I think ideally I would have signal "onPlanetareaentered(area)" inside the spaceship script that sets the orbit to be circular around that planet.

I have messed around with the point gravity in Area2D and it only seems to give me elliptical orbits. I was also thinking it may work to have a wave function set as the point gravity value in Area2D, but I could not figure out how to have a wave function as a value in an inspector field.

example of what I want in green vs what I'm getting with area2D, in red

Godot version 3.3
in Engine by (14 points)

I'm also new to Godot but I call tell you something. The red line is correct, your object is probably too fast to orbit the Area2. I have two ideas about that, and they aren't direct solutions, so this is a comment. Learn physics (I'm physicist) and understand how speed and other parameters affect the orbit, then if your object has the correct speed to enter in a circular orbit, when you want, make a boost in the velocity via code to exit the orbit. The second option is to apply some maths and find a way to describe the trajectory you want with trigonometic functions to orbit and a right line to exit (physics is not always needed in videogames). That's only my opinion, not trivial solution.

Please log in or register to answer this question.

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 Frequently asked questions and 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 [email protected] with your username.