Skip to content

Instantly share code, notes, and snippets.

@chabiribon
Created January 22, 2015 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chabiribon/d72f68aa461230dd9a99 to your computer and use it in GitHub Desktop.
Save chabiribon/d72f68aa461230dd9a99 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class Move_A : MonoBehaviour {
// Use this for initialization
void Start () {
}
public float speed_a = 0.1f;
Rect _rect = new Rect(300,0,300,1000);
// Update is called once per frame
void Update () {
GameObject obj1 = GameObject.Find("Player");
if (Input.touchCount > 0) {
Touch _touch = Input.GetTouch(0);
Vector2 newVec = new Vector2(_touch.position.x,Screen.height - _touch.position.y);
if(newVec.x >= _rect.xMin && newVec.x < _rect.xMax
&& newVec.y >= _rect.yMin && newVec.y < _rect.yMax){
obj1.transform.Translate(speed_a,0,0);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment