Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Simulating ZERO-GRAVITY

Discussion in 'Physics' started by Merendeiro, Nov 20, 2016.

  1. Merendeiro

    Merendeiro

    Joined:
    Nov 10, 2016
    Posts:
    8
    Hi everyone!!
    During my spare time I'm working on a project for Google Cardboard. I would like to find a way to set up view and rotation of the camera to simulate ZERO-GRAVITY as well as the user were an astronaut moving freely inside a space module.
    Any ideas?
     
  2. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    289
    Go to Edit / Project Settings / Physics2D and you can edit the gravity there.
     
  3. Merendeiro

    Merendeiro

    Joined:
    Nov 10, 2016
    Posts:
    8
    Really thanks guys!! XD
     
  4. Maverickthebest

    Maverickthebest

    Joined:
    Jul 27, 2018
    Posts:
    4
    but it effects every scene Correct?
     
  5. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,754
    Gravity is nothing more, than just add force to rigid body. So you can turn of gravity in physics settings, and make own, as you like.

    However, a bit old post :)
     
  6. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    Necro posting is a plague around here, eh?

    Yes, physics setting are global to the project.

    I surprised no one mentioned the fact you can just tick off "UseGravity" on the rigidbody.
    I also like to note that there actually IS gravity is space, but let's not get into this right now.
     
    Joe-Censored, knobblez and Antypodish like this.
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    The information is not redundant therefore it's fine.

    No, it's relatively uncommon given the amount of traffic the forum gets.

    Just people for some reason fear the dreaded horned necro.
     
    ZO5KmUG6R likes this.
  8. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I saw Physics2D mentioned, so would just like to point out that Rigidbody2D doesn't have a UseGravity setting. Instead I believe you adjust gravityScale to 0. Doesn't make sense to me why this is the case.

    https://docs.unity3d.com/ScriptReference/Rigidbody2D-gravityScale.html
     
  9. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    Because this is a feature of Box2D we expose directly. Also, it provides more flexibility over just turning if on/off i.e. you can scale the global gravity for individual objects, even invert it etc.
     
    Joe-Censored likes this.
  10. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,967
    You can also just set the gravity scale on the rigidbody 0, that way you dont have to completely remove gravity across entire project, only for objects you mark.
     
  11. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    So why not do that on the 3D version too?
    why only a bool?
     
  12. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    Because 3D is Physx not Box2D and I can only assume it only has a flag to turn it on or off only which is why back in the day it was implemented as a bool. Both systems cannot always be identical unfortunately.
     
    SparrowGS likes this.
  13. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    The extra flexibility is nice, but what doesn't make sense to me is that the same on/off wasn't also included to maintain uniformity with Rigidbody3D.
     
  14. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I dunno about keeping them consistent for the sake of it. I really appreciate Physx being quite close API wise (where possible) to the actual library, because I was able to look up docs on nvidia and improve my simulation.

    Same with Box2D being centric to its own thing. I don't actually know why these 2 separate systems would need the same API to do similar things unless I was constantly hopping back and forth between a 2D and 3D project and perhaps got annoyed with intellisense.