Ejemplo n.º 1
0
    private Vector3 previousMousePosition;   //!< Keeps track of delta movements
    // Use this for initialization

    /*!
     * Sets member functions
     */
    void Start()
    {
        mainCam         = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();
        spellController = GameObject.FindGameObjectWithTag("SpellController").GetComponent <SpellController>();
        gameController  = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();

        lineren               = GetComponent <LineRenderer>();
        player                = GameObject.FindGameObjectWithTag("Player");
        targetPos             = player.transform.position;
        playerPos             = new Vector3(player.transform.position.x, 0.0f, player.transform.position.z);
        osuTime               = spellController.GetOsuTime();
        previousMousePosition = Vector3.zero;
    }
Ejemplo n.º 2
0
    /*!
     * Updates last since it is GUI element to eleminate apparent UI issues
     */
    void LateUpdate()
    {
        playerPos = new Vector3(player.transform.position.x, 0.0f, player.transform.position.z);
        lineren.SetPosition(0, playerPos);

        if (!gameController.playerIsFiring)
        {
            previousMousePosition = Input.mousePosition;
        }

        camRay = mainCam.ScreenPointToRay(previousMousePosition);
        if (Physics.Raycast(camRay, out camRayHit))
        {
            targetPos = new Vector3(camRayHit.point.x, 0.0f, camRayHit.point.z);
            transform.LookAt(targetPos);
            transform.eulerAngles = transform.eulerAngles + 180 * Vector3.up;
        }

        osuTime   = spellController.GetOsuTime();
        targetPos = (-(playerPos - targetPos).normalized * osuTime) + playerPos;
        lineren.SetPosition(1, targetPos);
    }