Search Unity

Rotating the level itself or camera and tricking the physics?

Discussion in 'Scripting' started by kepler64b, Aug 22, 2017.

  1. kepler64b

    kepler64b

    Joined:
    Aug 9, 2017
    Posts:
    16
    I am trying to achieve an effect in which by pressing left or right, the level rotates (gravity axis stays the same).
    So as you rotate the level, a ball then reacts to the changing orientation of the level and rolls whichever way the gravity forces it to.

    (I am rotating it in the inspector, transform panel for explaining purposes)
    http://i.imgur.com/DvnTkLt.gifv

    What would be the most optimal thing to do? Rotate the level itself or rotate the camera and "trick" gravity by applying forces in whichever gravitational axis it needs, to match camera rotation? :rolleyes:
     
    Kudorado likes this.
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,527
    Kudorado, kepler64b and DroidifyDevs like this.
  3. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    I agree with @lordofduct, it could be as simple as "Physics.gravity = -Camera.main.transform.up" for every frame the camera is rotating.
     
    Kudorado and kepler64b like this.