Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

[C#] guitexture as button for player move on iOS/android

$
0
0
i can't make my player move to right when i touch the button this my script: MY TOUCH LOGIC using UnityEngine; using System.Collections; public class TouchLogic : MonoBehaviour { public static int currtouch = 0;//make other script know what touch currently on screen void Update() { if(Input.touches.Length <= 0) { } else { for( int i = 0; i < Input.touchCount; i++) { currtouch = i; Debug.Log(currtouch); if(this.guiTexture != null && (this.guiTexture.HitTest(Input.GetTouch(i).position))) { if(Input.GetTouch(i).phase == TouchPhase.Began) { this.SendMessage("Thit"); } if(Input.GetTouch(i).phase == TouchPhase.Ended) { this.SendMessage("Tend"); } if(Input.GetTouch(i).phase == TouchPhase.Moved) { this.SendMessage("Tmove"); } } } } } } AND MY PLAYER: using UnityEngine; using System.Collections; public class player : TouchLogic { public GUITexture guit = null; public float speedplayer = 5f; bool Touch = true; void Thit() { if(guit == Touch) { transform.Translate (Vector3.right * speedplayer * Time.smoothDeltaTime); } } }

Viewing all articles
Browse latest Browse all 4709

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>