示例#1
0
    // Used for following mouse and tilting
    void Update()
    {
        // Tilt this GameObject as it is being dragged either by a player or an NPC
        if (followMouse)
        {
            //print("Following mouse");
            if (!npcdrag)
            {
                //print("NPC NOT dragging");
                Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                mousePosition.z    = -1.0f;
                transform.position = offset + mousePosition;
                transform.rotation = drag.Tilt(transform.position);
            }
        }
        else
        {
            //print("Not following mouse");
            if (npcdrag)
            {
                //print("NPC IS dragging");
                if (this.GetComponent <LerpTest>().moving)
                {
                    //Vector3 p = transform.position;
                    //p.z = -1.0f;
                    //transform.position = p;

                    transform.rotation = drag.Tilt(transform.position);

                    //print(transform.position);
                }

                if (!this.GetComponent <LerpTest>().Moving())
                {
                    EndTiltLerp();
                }
            }
            else
            {
                //print("NPC is NOT dragging");
                transform.rotation = drag.ResetTilt();

                if (FinishedRotating())
                {
                    if (!positionSet)
                    {
                        SetPosition(transform.position);
                    }
                }
            }
        }
    }
示例#2
0
 // Update is called once per frame
 void Update()
 {
     if (followMouse)
     {
         Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         mousePosition.z    = 0.0f;
         transform.position = offset + mousePosition;
         transform.rotation = drag.Tilt(transform.position);
     }
     else
     {
         transform.rotation = drag.ResetTilt();
     }
 }