Ejemplo n.º 1
0
    void Update()
    {
        // Rotate player to match mouse target
        transform.rotation = MouseUtils.GetSlerpedAngleToMouse(transform, Mouse.RotationSlerpRatio * Time.deltaTime, -90f);

        // Calculate player movement in response to keyboard input
        // TODO: Handle stamina/energy drain
        bool isRunning = Input.GetKey(KeyCode.LeftShift);

        Vector2 moveInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));

        velocity = Movement.GetTargetVelocity(moveInput.normalized, isRunning);

        // Handle firing weapon
        if (Input.GetMouseButtonDown(0) && Weapon != null)
        {
            Weapon.Fire(Camera.main.ScreenToWorldPoint(Input.mousePosition));
        }
    }