Example #1
0
        private void onMovement(Vector3 Move)
        {
            float multX = (Move.x < 0) ? -1 : 1;
            float multY = (Move.y < 0) ? -1 : 1;

            Move.x  = (Move.x == 0) ? 0 : 1;
            Move.x *= multX;
            Move.y  = (Move.y == 0) ? 0 : 1;
            Move.y *= multY;

            animator.SetFloat("x", (Move.y != 0) ? 0 : Move.x);
            animator.SetFloat("y", Move.y);

            lastMove = Move;

            networkTransform.SendMoveCommand((int)Move.x, (int)Move.y);

            if (Move.x != 0 && Move.y != 0)
            {
                Move *= 0.75f; //Half speed when walking diagonal
            }

            transform.position += Move * playerStats.GetSpeed() * Time.deltaTime; //Local move to avoid lag
            oldPosition         = transform.position;
        }