title: How would I make my player move with on screen button?
body: <p>As the title says, how do I do that in Unity with C#? I have tried some things myself, but with the things I tried, my player always glitched out of the screen. So I was wondering how it should be done.
  <a href="http://pastebin.com/q60xgvZM" rel="nofollow">http://pastebin.com/q60xgvZM</a> - PlayerScript.cs
  <a href="http://pastebin.com/AuHzYhtH" rel="nofollow">http://pastebin.com/AuHzYhtH</a> - MoveScript.cs (I don't know if this one if useful for you guys)
  And here is my GameButtons.cs where I was trying to make the buttons in (don't mind the comments. I like to copy and paste):</p>
  
  <pre><code>using UnityEngine;
  
  public class GameButtons : MonoBehaviour
  {
      void OnGUI()
    {
      const int buttonWidth = 60;
      const int buttonHeight = 60;
  
      // Draw a button to start the game
      if (
        GUI.Button(
          // Center in X, 2/3 of the height in Y
          new Rect(
            Screen.width / 5 - (buttonWidth / 2),
            (3 * Screen.height / 4) - (buttonHeight / 2),
            buttonWidth,
            buttonHeight
          ),
          "UP"
        )
      )
      {
        // On Click, load the first level.
        // "Stage1" is the name of the first scene we created.
        speed.x += Vector2.up * 10;
      }
          if (
        GUI.Button(
          // Center in X, 2/3 of the height in Y
          new Rect(
           Screen.width / 5 - (buttonWidth / 2),
            (13 * Screen.height / 14) - (buttonHeight / 2),
            buttonWidth,
            buttonHeight
          ),
          "DOWN"
        )
      )
      {
        // On Click, load the first level.
        // "Stage1" is the name of the first scene we created.
        speed.y += Vector2.down * 10;
      }
          if (
        GUI.Button(
          // Center in X, 2/3 of the height in Y
          new Rect(
            Screen.width / 8 - (buttonWidth / 2),
            (5 * Screen.height / 6) - (buttonHeight / 2),
            buttonWidth,
            buttonHeight
          ),
          "LEFT"
        )
      )
      {
        speed.x += Vector2.left * 10;
      }
          if (
        GUI.Button(
          // Center in X, 2/3 of the height in Y
          new Rect(
            Screen.width / 4 - (buttonWidth / 2) + 24,
            (5 * Screen.height / 6) - (buttonHeight / 2),
            buttonWidth,
           buttonHeight
          ),
          "RIGHT"
        )
      )
      {
        // On Click, load the first level.
        // "Stage1" is the name of the first scene we created.
        speed.y += Vector2.right * 10;
      }
          if (
        GUI.Button(
          // Center in X, 2/3 of the height in Y
          new Rect(
            (Screen.width / 1) - (buttonWidth * 2) - 20,
            (5 * Screen.height / 6) - (buttonHeight / 2),
            buttonWidth,
            buttonHeight
          ),
          "FIRE"
        )
      )
      {
        // On Click, load the first level.
        // "Stage1" is the name of the first scene we created.
        Application.LoadLevel("ShootEmUp");
      }
    }
  }
  </code></pre>