Can't use mouse movement

After input for controller and gamepad in playerMovement.cs i can’t use mouse movement, any solution for that?
here is the code:

ThirdPersonCharacter m_Character;   // A reference to the ThirdPersonCharacter on the object
CameraRaycaster cameraRaycaster;
Vector3 currentClickTarget;

bool isInDirectMode = false; // Todo consider making static later

private void Start()
{
    cameraRaycaster = Camera.main.GetComponent<CameraRaycaster>();
    m_Character = GetComponent<ThirdPersonCharacter>();
    currentClickTarget = transform.position;
}

// Fixed update is called in sync with physics
private void FixedUpdate()
{
    if (Input.GetKeyDown(KeyCode.G)) // G for gamepad. TODO allow player to map later
    {
        isInDirectMode = !isInDirectMode; // toggle mode
    }

    if (isInDirectMode)
    {
       ProcessDirectMovement();
    }
    else
    {

        ProcessMouseMovement();
    }
}

private void ProcessDirectMovement()
{
    float h = Input.GetAxis("Horizontal");
    float v = Input.GetAxis("Vertical");

    // calculate camera relative direction to move:
    Vector3 m_CamForward = Vector3.Scale(Camera.main.transform.forward, new Vector3(1, 0, 1)).normalized;
    Vector3 m_Move = v * m_CamForward + h * Camera.main.transform.right;

    m_Character.Move (m_Move, false, false);
}

private void ProcessMouseMovement()
{
    if (Input.GetMouseButton(0))
    {
        switch (cameraRaycaster.layerHit)
        {
            case Layer.Walkable:
                currentClickTarget = cameraRaycaster.hit.point;
                break;
            case Layer.Enemy:
                print("Not moving to enemy");
                break;
            default:
                print("Unexpected layer found");
                return;
        }
    }
    var playerToClickPoint = currentClickTarget - transform.position;
    if (playerToClickPoint.magnitude >= walkMoveStopRadius)
    {
        m_Character.Move(playerToClickPoint, false, false);
    }
    else
    {
        m_Character.Move(Vector3.zero, false, false);
    }
}

Solved it by my self.

Privacy & Terms