Last active
August 29, 2015 14:13
-
-
Save MhdSyrwan/9d991c4214133dfb8675 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 move2 : MonoBehaviour { | |
public float xx; | |
public float yy; | |
//public bool destroyy=false; | |
public GameObject shap; | |
float x,y; | |
// Use this for initialization | |
void Start () { | |
} | |
// Update is called once per frame | |
void Update () { | |
} | |
bool dragStarted = false; | |
void OnMouseDrag () | |
{ | |
x = Input.mousePosition.x; | |
y = Input.mousePosition.y; | |
if (!dragStarted) { | |
dragStarted = true; | |
xx = x; | |
yy = y; | |
} | |
Vector2 pos = Camera.main.ScreenToWorldPoint (new Vector2 (x, y)); | |
transform.position = new Vector3 (pos.x, pos.y, transform.position.z); | |
} | |
void OnTriggerStay2D(Collider2D other) | |
{ | |
//test the shap | |
if (shap.collider2D == other) { | |
Debug.Log ("trigger"); | |
Destroy(gameObject, 1f); | |
} | |
else | |
Debug.Log("no trigger"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment