Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Discussion Zero Gravity FPS Movement

Discussion in 'Scripting' started by BlackSabin, Dec 13, 2022.

  1. BlackSabin


    Feb 27, 2021
    To start, I've labelled this a discussion as "Question" doesn't feel appropriate. This is me more trying to drum up ideas and brainstorm how to tackle this particular issue.

    I'm currently working on a FPS that takes places in environments that vary between the types of gravity present at any given time. Moreover the camera system is to acknowledge that there is no true "up" as is the case in space; IE camera pivot is not clamped between -90 and 90 degree angles. Rigidbody, thankfully, has taken care of 98.5% of the math and calculations behind this; I can simply call AddForce() and voila, I have movement. The issue comes to the rotation of the camera, and subsequently the player.

    My first approach had the camera setting it's rotation, as many FPS do. The collision capsule was more than sufficient for the parts that had some semblance of a ground; but when it came to the 0G aspect that no longer worked. If my character was in a right-angled corner or even parallel to the ground as opposed to perpendicular, the camera could be rotated to place the character *within* the ground. Clearly, setting the rotation directly to the camera's movements will not work. Either some other processing needs to be done or a different approach is required.

    I have my own solution I'm attempting currently, but on the suspicion that this is more "band-aid" in terms of a resolution I've decided to inquire here.

    How would you implement a 0 gravity FPS camera? Requirements include ignoring a "true up" scenario, and of course, not clipping into walls by rotating.
  2. RadRedPanda


    May 9, 2018
    If you're rotating the player using the Rigidbody method MoveRotation instead of just setting the transform, it won't phase through the ground.
    BlackSabin likes this.
  3. spiney199


    Feb 11, 2021
    If you've seen people float through zero G (such as astronauts on the international space station) you'll notice they tumble through it head first. I've also noticed most games take this approach, and when you're in very low or zero gravity your player kinda has 'no legs'.

    So you could easily take this approach and shrink a capsule collider when in zero gravity, probably down to a sphere. Once you hit regular gravity you restore the capsule shape to it.
    BlackSabin likes this.
  4. Kurt-Dekker


    Mar 16, 2013
    I have a playground for this stuff if you wanna quickly fool around with ideas.

    Check out my Proximity Buttons package and go to the

    It is presently set up as a first person lunar lander: big motor underneath, settable to sustain or thrust or off.

    This means it's intended to work with gravity to lift off and tilt forward.

    But if you turn off gravity you can add your own forces in any directional axis you want, see what it feels like to drift-maneuver in 3D. It's kinda ... difficult!


    proximity_buttons is presently hosted at these locations:
    Last edited: Dec 13, 2022
    BlackSabin likes this.
  5. BlackSabin


    Feb 27, 2021
    Never even knew this existed, this practically solved the issue entirely lol. Massive thanks!

    Thats a great idea, especially considering it makes sense. I think I'll see if I can't figure out making the player go more parallel instead of simply shrinking the capsule first though; the game I intend to create has shooting and it'd probably be frustrating for other players to simply have less hitbox to shoot just because they're in space.

    And @Kurt-Dekker: this forum needs more of you, honestly. I feel like each of my posts has a response from you with something of help.

    EDIT: @Kurt-Dekker I meant more people like you, not more of you. Hope that didn't get taken the wrong way ._.
    Last edited: Dec 14, 2022
  6. Max-om


    Aug 9, 2017
    There is a VR game called lone echo which take place in zero g. You have a body there and it feels very intuitive. If you use the thrusters to accelerate and the turn around 180 and float on your back it feels awsome :)


    I think this could be translated to desktop too
    Kurt-Dekker likes this.