Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How can i move the player with the new UI system??

Discussion in 'UGUI & TextMesh Pro' started by Ericmatheus, Dec 28, 2014.

  1. Ericmatheus

    Ericmatheus

    Joined:
    Aug 11, 2014
    Posts:
    68
    i know how to move with GUI ,but with UI no
     
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    What exactly do you want? Which part of your solution that works with the GUI does not work with the UI?
     
  3. Ericmatheus

    Ericmatheus

    Joined:
    Aug 11, 2014
    Posts:
    68
    Move right and left with UI ....
     
  4. Ericmatheus

    Ericmatheus

    Joined:
    Aug 11, 2014
    Posts:
    68
    The problem is that when i click on UI , the player does'nt move constantly
     
  5. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    How does the code look for the GUI and how does it look for the UI?
     
  6. Ericmatheus

    Ericmatheus

    Joined:
    Aug 11, 2014
    Posts:
    68
    using UnityEngine;
    using System.Collections;
    public class Movernave : MonoBehaviour {

    public float speed = 0f;
    public Vector3 pos;
    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {
    transform.Translate (speed * Time.deltaTime,0,0);

    }


    public void AdjustSpeed (float newSpeed) {
    speed = newSpeed;
    //Debug.Log (newSpeed);


    }
    }
     
  7. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Kiwasi likes this.
  8. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Simply add your AdjustSpeed method with an appropriate float to th OnClick listener on your button.
     
  9. Ericmatheus

    Ericmatheus

    Joined:
    Aug 11, 2014
    Posts:
    68
    But the player just move if i click,i want when i hold the UI touch,hte player move constantly
     
  10. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667

    Jump to 3:22
     
  11. Ericmatheus

    Ericmatheus

    Joined:
    Aug 11, 2014
    Posts:
    68
    Ok thanks everbody