Skip to content

Instantly share code, notes, and snippets.

@MhdSyrwan
Last active August 29, 2015 14:13
Show Gist options
  • Save MhdSyrwan/9d991c4214133dfb8675 to your computer and use it in GitHub Desktop.
Save MhdSyrwan/9d991c4214133dfb8675 to your computer and use it in GitHub Desktop.
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