I am making a game (I have just 2 or 3 months of experience on godot)

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

I want to have a sphere which simulates planet and a car that runs on it without getting floating away from the planet i.e I want a spherical gravity which should hold my car and not let it fly away. Pls help me

First of all, please use titles for your questions that already tell readers what your question is about. “How to implement spherical gravity” would have been a better title. Also, the tag “help” doesn’t really help others understand which category your question falls into.

Next, your question does not show that you have tried at least one or two approaches on your own. Most forums don’t work in the way that users cry for help and just get their work done for them.

Lastly, be as precise as possible when describing your plan. I still don’t get what you want to do. Is it supposed to be a simulation where the car follows a pre-defined track? Then you might want to take a look at Godot Docs under Your first game, where a Path2D node is used to spawn enemies. Maybe using a similar technique you can have your car follow that track.
Or is the car user-controlled and of the sphere only part is ever shown so that your project rather resembles a racing game? Then you might get some ideas from following people like HeartBeast on YouTube, who, among other things, discuss such aspects of Godot.

ChristianSF | 2020-07-27 17:11

2D or 3D? Have you written any code for it yet? Is the car player-controlled? You can use a RigidBody- and an Area-node with custom gravity (check the inspector!).

njamster | 2020-07-27 14:00

Thanx for replying to my answer. But now I am able to simulate the player and the planet like I want .I used kinematic body instead and the wrote some code to calculate the slope angle and the added gravity dir function to simulate gravity. But I appreciate your help and I’ll surely try the way you told .(actually I tried it out but I failed several times). By the way my player is not a vehicle body. pls reply to this writing the exact solution pls I need it .

Dinoking | 2020-07-27 14:06

Sorry for the lack of info caused by my explaination of the question. Actually I am making a game in which a player has to move around a planet with a car (not car actually it’s a rigid body). I tried to simulate a spherical gravity with area node but my rigid body flies away from the planet . I tried to do whatever I understood but not able to keep my rigid body on the planet surface. So I hope now my question is clear:) .And thanks for replying and advicing me on how to post questions on forums. I would surely post the way you told next time.And yes it’s a 3d game.

Dinoking | 2020-07-28 04:38