Make cursor work after scene change

Hello, I have recently started my new FPS project, and I was making a death screen once the player fell, and I was wondering if anyone knows how to make the cursor work after a scene change. Here’s what I already tried:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DeathCursor : MonoBehaviour {

    void Awake () {
        Cursor.visible = true;
       
    }
   
    void Update () {
        Cursor.visible = true;
    }
}

But when I die, it only shows my cursor, and I’m wondering if there’s a way to make the cursor function.

Thanks

1 Answer

1

Hi,

It may depend on how the rest of your game is set up, but have you tried using Cursor.lockState? so the method would look something like this:

    void Awake () {
        Cursor.visible = true;
        Cursor.lockState = CursorLockMode.Confined;
    }

Make sure to not use Cursor.lockState in the Update() method as it can cause flickering and other strange behavior.

This doc has other uses for the Cursor.lockState:

I hope this is helpful.