Search Unity

any hints on making a GUI dial to rotate an object 360 degrees

Discussion in 'Immediate Mode GUI (IMGUI)' started by Krodil, Jun 23, 2013.

  1. Krodil

    Krodil

    Joined:
    Jun 30, 2010
    Posts:
    141
    hey,
    heading probably says it.
    I would appreciate any input on how to make a dial (like this:
    HTML:
    http://www.dokisoft.com/wp-content/uploads/2012/10/11c-dial-2.jpg
    )
    The idea is to map degrees with the object's, and making the obj rotate around its y-axis.
    Im thinking a circular 'slider' or so, but how to make that?

    I am using fingergestures btw, but that might be irrelevant,

    any input is much appreciated!:)
    best,
     
  2. dkozar

    dkozar

    Joined:
    Nov 30, 2009
    Posts:
    1,410
    I would use radial coordinates.

    That is, I would convert the X, Y you get from your input system to degrees.

    Of course, only if the click happened inside of the circle.
     
  3. Krodil

    Krodil

    Joined:
    Jun 30, 2010
    Posts:
    141
    That seems like a good idea!
    do you mean like if the user clicks in whatever x,y area it would correspond to a radial degree?

    Have a look at the figure:
    for instance by using a lot of small 3d objects and raycasting:
    e.g. the user clicks on any of those divisions of a circle (the figure is for illustrative purposes only), so the object touched would message the object to rotate lets say 45degrees etc. the more divisions of the circle the more degrees to rotate. (max 360 objects of course)


    does this even make sense? :)
     

    Attached Files:

  4. dkozar

    dkozar

    Joined:
    Nov 30, 2009
    Posts:
    1,410
    What I meant is: when the user touches inside of the circle, take this point as and save it as a starting angle.

    Whenever the user moves a finger, calculate the new angle based on the current point.

    Subtract the two angles and you will get the wheel offset from the starting angle.
     
unityunity