Search Unity

Control Scheme

Discussion in '2D' started by rudy0912, Jan 11, 2014.

  1. rudy0912

    rudy0912

    Joined:
    Jan 11, 2014
    Posts:
    3
    Hi everyone

    I'm learning the basics of unity2d and I need help coming up with a control scheme that I want to implement for mobile phones.

    I want to create some type of button at the bottom right of the screen that would remotely control the turret that is sticking out of the base (the turret and base are separate gameobjects). If the user is touching the button and moves his/her finger to the left, the turret should match that and same for moving right. So basically I want the turret object to rotate on a point based on touch input from a remote button.

    Here is an image of my scene so far (excuse the awful paint art): http://i.imgur.com/ZO3oMyz.png

    Any help would be appreciated. Thank you.
     

    Attached Files:

  2. unitylover

    unitylover

    Joined:
    Jul 6, 2013
    Posts:
    346
  3. rudy0912

    rudy0912

    Joined:
    Jan 11, 2014
    Posts:
    3
    Thanks for the response. I actually saw your tutorial the night before I posted my question :)
    I was able to get a guitexture on my screen that recognizes whether the user is swiping left or right. However, I'm having a lot of problems trying to rotate the turret. I've tried rotating it with different axis values but none of them seem to work. I want the turret to rotate on a point...any ideas on this?
     
  4. unitylover

    unitylover

    Joined:
    Jul 6, 2013
    Posts:
    346
    Set the pivot point of the turrent barrel (you want to make this a separate sprite) to the bottom and use rigidbody2D.AddTorque() or transform.Rotate() on it.