示例#1
0
    private void positionReticles()
    {
        //AOE
        Vector3 reticlePos = mousePos.getMouseWorldPoint();

        reticle_AOE.transform.position = reticlePos;
        reticle_AOE.transform.Rotate(Vector3.up * Time.deltaTime * 20f);

        //Directional
        reticle_Direction.transform.position = transform.position;
        Vector3 targetTransform = mousePos.getMouseWorldPoint();

        reticle_Direction.transform.LookAt(new Vector3(targetTransform.x, targetTransform.y, targetTransform.z));
    }
    void FixedUpdate()
    {
        if (canPlayerMove)
        {
            currentSpeed = rb.velocity.sqrMagnitude;
        }
        else
        {
            currentSpeed = 0;
        }
        anim.SetFloat("m_MoveSpeed", currentSpeed);
        #region Key pressed action
        if (Input.GetKey(KeyCode.Mouse1))
        {
            if (_teleportToShop.teleportingToShop)
            {
                _teleportToShop.StopPlayerRecall();
            }
            targetPosition    = mouseController.getMouseWorldPoint();
            targetPosRotation = targetPosition;
            moving            = true;
            anim.SetBool("Cast", false);

            //Update MoveIndicator
            moveIndicator.UpdateMoveIndicator(targetPosition);
        }
        #endregion

        if (canPlayerMove)
        {
            #region Movement
            if (moving)
            {
                moveDir  = targetPosition - transform.position;
                distance = moveDir.sqrMagnitude;

                if (distance < distanceToStop * distanceToStop)
                {
                    moving = false;
                }
                else
                {
                    FollowTarget(targetPosition, movementSpeed);
                }
                RotateToPos();
            }
            ;
            #endregion
        }

        if (Time.time >= timeStamp + slowDuration)
        {
            movementSpeed = originalSpeed;
        }
    }