- Home /
Question by
Bohdan-Shpytko · Jun 02, 2015 at 11:23 AM ·
c#androiduitouch
Character Controller with Unity User Iterface input
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;
}
}
Comment
Answer by Saad_Khan · Jun 02, 2015 at 11:48 AM
You can refer to the following link where I have answered a similar question, check out the recommended solution:
http://answers.unity3d.com/questions/977120/how-to-replace-input-axis-keyboard-button-with-tou.html
Your answer
Follow this Question
Related Questions
How to prevent touch going through UI? 3 Answers
[Edited]-Android-swap position on touch 1 Answer
GUI.Button Touch Input Problem 1 Answer