Search Unity

how do you code ui buttons to recieve touch input to control 2D character?

Discussion in 'Scripting' started by rory_chang05, Aug 1, 2020.

  1. rory_chang05

    rory_chang05

    Joined:
    May 16, 2020
    Posts:
    12
    I have a right, left and up button on the screen (its a 2D game). I am trying to figure out how to write a script so that when the user clicks the buttons, they receive the input and either move the player right left or up. I have watched some tutorials on youtube but they are from a couple of years ago and are out of date and don't work for me. Could anyone send me a script or tell me how to code it (c#) so that it can recognise the touch input?
     
  2. Terraya

    Terraya

    Joined:
    Mar 8, 2018
    Posts:
    646


    CodeMonkey, very experienced 2D Coding ytber
     
  3. rory_chang05

    rory_chang05

    Joined:
    May 16, 2020
    Posts:
    12
    thanks, I was actually looking for how to get the input of when a user touches the screen where there will be a button and make that control the player instead of the keyboard as i am trying to make my game have a mobile version equivelant, do you or anyone else know how?
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,726