How to simulate moon gravity?

Hello! For 7DFPS I’m making a game where you are an astronaut exploring a moon, but I have a problem. I need to have gravity which centers around the moon, which is a sphere. I’ve looked at a lot of similar questions, but none of them work for me! Just a heads up, I’m using the first person controller. Do any of you know how to achieve?

In your used “First Person Controller” in Inspector, go to Character Motor(Script) -->Movement and change Max Ground Accelaration to 15, Max Air Acceleration to, lets say 4, also Gravity to 10 and Max Fall Speed to 2. Now you jump and fall slowly, just like on moon.

Hi, lowering the options like gravity for your fps moving capsule could be the option ( if your using default mesh).

Well, acoording Newton’s gravitation law, this can be simplified to a force acting on your character, assuming the force vector should always point to the planet’s (in your case, the moon’s) gravity center, so the sphere center (the moon’s gameObject transform.position). So you just have to apply a force on your character, and rotate the force vector so it always looks at the center of the moon.

Also, you cannot work with forces if you aren’t on a rigidbody. If you’re using the FPS controller, I assume you are using a character controller. This can be easily fixed, as forces are proportional to the acceleration they provoke, so accelerating your character towards the center of the moon should do that same effect. Just some easy physics.

Here’s a little bit of pseudo-coding of what I’m talking about:

define a Vector3 variable called acceleration;

Update function (){
    acceleration = Vector3(0,0,gravity);
    make acceleration look at the center of the moon
    transform.position += acceleration*time.deltaTime

That should do it. Actually, I don’t remember if there’s a function to make a vector “look” to a given point, but there should be one, if not, you’ve got the transform.lookAt() method, then you could use that transform’s forward vector to give a direction to your acceleration.

EDIT: Check out the Vector3.RotateTowards() method, I don’t know if it’s what you’re looking for, else you’ll have to work with a transform instead of a vector3 in order to use transform.lookAt()