Search Unity

Zero Gravity

Discussion in 'Scripting' started by MaesterGhaleon, Mar 3, 2010.

  1. MaesterGhaleon

    MaesterGhaleon

    Joined:
    Mar 2, 2010
    Posts:
    19
    Can anyone help me and my team are trying to manipulate the physics in code to remove all opposing forces from the player. This way i can allow my player to fly in a total freedom as if in space.
     
  2. Mirage

    Mirage

    Joined:
    Jan 13, 2010
    Posts:
    230
    I have a flight sim script I could PM you. It was designed for ships, but I left all the variables open to change. If you want it let me know.
     
  3. MaesterGhaleon

    MaesterGhaleon

    Joined:
    Mar 2, 2010
    Posts:
    19
    Yes i would like that. I am new to unity and its scripting so if you don't mind could you please PM that script to me.
    Thank you
     
  4. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    The main things you need to disable are gravity and drag. As far as I know, the rest of the physics is the same for space as anywhere else.
     
  5. MaesterGhaleon

    MaesterGhaleon

    Joined:
    Mar 2, 2010
    Posts:
    19
    I am not sure how to disable drag I am however looking into it. But Does anyone know how to set it so my up and down rotation with my mouse has no limits. You know Like a person doing front flips in space.
     
  6. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    The rigidbody component has two fields for the drag and angular drag - just set both of these to zero.

    As for the mouse movement, you can make the rotation continuous by adding torque on the appropriate axis rather than using quaternions for rotation. For example, if you wanted to rotate left/right, you would add torque around the local Y axis:-
    Code (csharp):
    1. rigidbody.AddRelativeTorque(Vector3.up * torqueStrength * Input.GetAxis("Mouse X");
     
  7. MaesterGhaleon

    MaesterGhaleon

    Joined:
    Mar 2, 2010
    Posts:
    19
    Thanks I think i am starting to get it