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

Suggestions on implementing a balancing feature?

Discussion in 'Physics' started by Dnileok, Mar 4, 2015.

  1. Dnileok

    Dnileok

    Joined:
    Mar 16, 2014
    Posts:
    6
    I am trying to implement a balancing feature. Basically the idea is the rigid body starts off balanced. Then over time the balance becomes increasingly difficult to maintain. The user will correct the balance by touching the screen on one side (either left or right). The further off of the screens center, the more counter force will be provided in that direction.

    I can't figure out how to implement a solution to this problem. My first thought was to use a sine wave that oscillates. To begin start off with the amplitude very small and slow increase as time progresses while at the same time increasing the frequency of the oscillations.

    While this seems like it would work I am having trouble thinking of how user input (i.e. actually balancing) would be implemented using this method.

    Then I thought of an inverted Pendulum since its hard to keep balanced and keeping it balanced requires forces which I may model via touch input. My lack of knowledge in physics is also giving me trouble with finding a reasonable solution. Would I be correct in saying to start by giving a force in one direction and measuring the angle from the equilibrium position. Then adding a force again based on user input. Calculating the new angle from equilibrium and so on? If this is a solution any ideas or suggestions on turning it into code? Like I said my lack of physics knowledge is leaving me stumped.