0
\$\begingroup\$

I have a player with a third person character controller component. i have a problem with the cursor lock it hide and cannot click the ui button. i already try some coding but error. SORRY Im very2 NEWBIE IN CODING IN UNITY

protected virtual void CharacterInit() { cc = GetComponent(); if (cc != null) cc.Init();

        tpCamera = FindObjectOfType<vThirdPersonCamera>();
        if (tpCamera) tpCamera.SetMainTarget(this.transform);


        Cursor.visible = false;
        Cursor.lockState = CursorLockMode.Locked;
    }
\$\endgroup\$
0
\$\begingroup\$

i think you mean mouse cursor. that only locks you cursor not hiding it. to hide you only need:

Cursor.visible=false;

remember best approach to use mouse cursor is to hide it in the game and set a sign in game ui and always give mouse position to it.

if you want to disable and enable mouse controll you can simply define a boolean variable.

bool UseCursor;
void Update(){
if(!useCursor) return;
// use mouse login here
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.