- Home /
Question by
Pibio · Sep 04, 2014 at 09:47 AM ·
touchguitexture
MultiTouch GUITexture Android
I just make one GUITEXTURE Buttons to move but, it's working fine but, when i use my jetpack to up i can't move to right and left some pro c# help me out? :) Thank you guys.. have a nice day.
here my code: using UnityEngine; using System.Collections;
public class PlayerController : MonoBehaviour { public GUITexture right; public GUITexture left; public GUITexture down; public GUITexture up;
public Vector2 moving = new Vector2();
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
moving.x = moving.y = 0;
if (Input.touchCount > 0) {
for (int i = 0; i < Input.touchCount; i++) {
if (right.HitTest (Input.GetTouch (0).position)) {
moving.x = 1;
}
if (left.HitTest (Input.GetTouch (0).position)) {
moving.x = -1;
}
if (up.HitTest (Input.GetTouch (0).position)) {
moving.y = 1;
}
if (down.HitTest (Input.GetTouch (0).position)) {
moving.y = -1;
}
}
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613162253im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Unity Web player doesn't finish the install, can you please help me? 0 Answers
Picking up an object 1 Answer
change font size help - impossible? 1 Answer