I have script. Then i press button that walk forward character was passed some way and stopped. So I want that when i press the ui button character walk until then I pressed the button.Function "forward"and “back” I added to ui button. This make for Android.
Please help me.
Unity 5
using UnityEngine;
using System.Collections;
public class Character : MonoBehaviour
{
private GameObject Player ;
public int Speed = 5;
void Start()
{
Player = (GameObject)this.gameObject;
}
public void forward()
{
Player.transform.position += Player.transform.forward * Speed * Time.deltaTime;
}
public void back()
{
Player.transform.position -= Player.transform.forward * Speed * Time.deltaTime;
}
}