Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("space"))
        {
            ResetPlanet();
        }

        /* Reset Object on Out of Screen Bounds */
        if (onClicked == 2 && transform.position.x > screenBounds.x + 5 || transform.position.x < -screenBounds.x - 5 ||
            transform.position.y > screenBounds.y + 5 || transform.position.y < -screenBounds.y - 5)
        {
            ResetPlanet();
            SEPlayer.playSE(6);
        }

        /* Dragging Object */
        if (onClicked == 1)
        {
            if (Input.GetMouseButton(0))
            {
                gameObject.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition) + mouseOffset;
            }
            if (Input.GetMouseButtonUp(0))
            {
                onClicked = 2;
                collided  = false;
                counter.Add(1);
                spring.enabled = true;
                SEPlayer.playSE(1);
            }
        }
        if (onClicked == 3)
        {
            RotateAround(GameObject.FindGameObjectWithTag("Planet"));
        }
    }