Created
January 22, 2015 01:28
-
-
Save chabiribon/d72f68aa461230dd9a99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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