Beispiel #1
0
    void OnMouseDrag( )
    {
        // This code moves the asteroid according on where the player is aiming.
        // It also adds force to the asteroid, relative to how far player drags.
        if (asteroidManager.asteroidOwner == GameManager.gameManager.TurnState)
        {
            asteroidManager.UpdatePlanetaryGravity(asteroidManager.orbitRadius, asteroidManager.orbitSpeed, null);

            transform.position = gameCamera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10));

            Vector3 allowedPos = clickPos - orbitPos;
            clickPos           = gameCamera.ScreenToWorldPoint(Input.mousePosition);
            allowedPos         = Vector3.ClampMagnitude(allowedPos, 3);
            transform.position = orbitPos + allowedPos;
        }
    }