Quantcast
Channel: Questions in topic: "up"
Viewing all articles
Browse latest Browse all 104

Input.GetTouch

$
0
0
Hi everyone, I got a simple question how can I make this touch script move in only one direction. For instance I want to move a block by touching my screen and sliding up only, once that happens the block moves only directly up. Heres the script. using UnityEngine; using System.Collections; public class TouchFunction : MonoBehaviour { public float speed = 0.1F; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) { Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition; transform.Translate(0, touchDeltaPosition.y * speed, 0); } } }

Viewing all articles
Browse latest Browse all 104

Trending Articles



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