0 votes

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

in Engine by (44 points)

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!).

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 .

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.

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.

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 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.