Drag rotate not working my projectile motion object?

Hi All,

I am making a simple projectile motion. my same requirement is

As above link, For that i have take one cannon maya object and added boxcollider and one empty game object for pivot. I have added this script but I can’t able to drag my object. how can fix that?

my code is like this:(from forms only i got code)

using UnityEngine;
using System.Collections;

public class DragRotate : MonoBehaviour {

public Transform pivot;
private float angle;
private Vector3 v3Pivot;  // Pivot in screen space

void Start () {
   v3Pivot = Camera.main.WorldToScreenPoint (pivot.position);

void OnMouseDown() {
   Vector3 v3T = (Vector3)Input.mousePosition - v3Pivot;
   angle = Mathf.Atan2 (v3T.y, v3T.x) * Mathf.Rad2Deg;

void OnMouseDrag() {
   Vector3 v3T = (Vector3)Input.mousePosition - v3Pivot;
   float angleT  = Mathf.Atan2 (v3T.y, v3T.x)  * Mathf.Rad2Deg;
   float angleDiff = Mathf.DeltaAngle(angle, angleT);
   pivot.Rotate(new Vector3(0.0f, 0.0f, angleDiff));
   angle = angleT;


I have to rotate my cannon type of object with 360 degrees.

I posted a script for this behavior a couple of days ago:


Before you try to integrate it into your existing code, create a new scene, drop in a block, and attach this script. That way you will get a good idea of how it should behave when you integrate it.