Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

change gravity

Discussion in 'Project Tiny' started by jrcanelalopez, Jan 16, 2019.

  1. jrcanelalopez

    jrcanelalopez

    Joined:
    Oct 8, 2016
    Posts:
    2
    How I can change gravity in Tiny Project?
    ut.Physics2D.Physics2DConfig.gravity is a read only data.

    Regards, Javi
     
  2. Nkon

    Nkon

    Unity Technologies

    Joined:
    Jun 12, 2017
    Posts:
    65
    Hi there,

    At runtime you can do it like this:

    Code (JavaScript):
    1. const physicsConfig = this.world.getConfigData(ut.Physics2D.Physics2DConfig);
    2. physicsConfig.gravity = new Vector2(0, 0);
    3. this.world.setConfigData(physicsConfig);
    If you wish to modify the default value, you can do it from the Editor. Select <yourproject>.utproject in the Project Window, then scroll down with the Inspector and you should find Configurations > Physics2DConfig right there. Note that the config is only visible if the Physics2D module is enabled.

    Cheers!
     
  3. jrcanelalopez

    jrcanelalopez

    Joined:
    Oct 8, 2016
    Posts:
    2
    Thank you, Nkon :)