drag and drop

August 6, 2013   ·   0 Comments

void Update () {	
        if(Input.GetMouseButtonDown(0)){
            Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast (ray, out hit, 100)) {
                Debug.DrawLine (ray.origin, hit.point);
                if (hit.transform.tag == "bird")
                {
					mouseDownPosition=Input.mousePosition;
                }
            }
        }else  if(Input.GetMouseButtonUp(0)){
			if(mouseDownPosition!=null){
			  Vector2 mouseUPPosition=Input.mousePosition;
		       debugvalue=mouseDownPosition-mouseUPPosition;
			   gameObject.rigidbody.AddForce(new Vector3(debugvalue.x,
					debugvalue.y,0)*10);
			}
		}
	}
shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Unity3D4

Amazon

adsbygoogle

Recent Posts

Categories

Amazon