示例#1
0
    private void ProcessMovement()
    {
        float xThrow = Input.GetAxis("HorizontalMove");
        float yThrow = Input.GetAxis("VerticalMove");

        // Only do things if there is an input
        if (Mathf.Abs(xThrow) > Mathf.Epsilon || Mathf.Abs(yThrow) > Mathf.Epsilon)
        {
            // If you move while channelling then cancel the channel
            if (channelling)
            {
                channelling = false;
            }

            float xOffset = xThrow * moveSpeed * Time.deltaTime;
            float yOffset = yThrow * moveSpeed * Time.deltaTime;

            Vector3 movementVector = new Vector3(xOffset, 0f, yOffset);
            transform.Translate(movementVector, Space.World);
            transform.rotation = Quaternion.LookRotation(movementVector.normalized);
        }

        tileMarker.transform.position = hexPosition.GetRealPosition();
    }