Forum rules - please read before posting.

Only show cursor when in a menu

The cursor settings Display cursor doesn't seem to have this option: I'd like to run around (with direct movement WASD) and have my cursor hidden, but then have it appear when I open specific menus (conversation, inventory, map, pause menu, etc.) Is there an option for this behavior that I'm missing? At the very least I'd like to hide the cursor when the player isn't moving the mouse.

Comments

  • The cusor can be locked and unlocked at runtime. To hide the cursor when it is locked, check Hide cursor when locked? in the Settings Manager's "Interface settings" panel.

    The cursor can also be locked by default here by checking Lock cursor in screen's centre when game begins?.

    To unlock the cursor at runtime, use the Player: Constrain Action's Cursor lock property. To run this when e.g. the Conversation Menu is turned on, assign an ActionList asset in the Menu's ActionList when turn on field.

  • Is there any way to just hide the cursor when the mouse hasn't been moved for a moment? A lot of games will have your cursor fade out after a second or two when you aren't using it so it doesn't get distracting on the screen. I'd like to be able to fade out the cursor when it hasn't moved for a second and you aren't in a menu

  • If you use Unity UI for your Cursor's rendering, you can attach a script that controls a Canvas Group's Alpha value to fade it out after a set time.

    Something along these lines would do it:

    using UnityEngine;
    using AC;
    
    public class NANTest : MonoBehaviour
    {
    
        public float waitTime = 2f;
        public float fadeSpeed = 2f;
        public CanvasGroup canvasGroup;
        private Vector2 lastFrameMousePosition;
        private float timeOfLastMove;
    
        void Update ()
        {
            if (timeOfLastMove + waitTime < Time.time)
            {
                canvasGroup.alpha = Mathf.Clamp01 (canvasGroup.alpha - fadeSpeed * Time.deltaTime);
            }
    
            Vector2 mousePosition = KickStarter.playerInput.GetMousePosition ();
            if (mousePosition != lastFrameMousePosition)
            {
                lastFrameMousePosition = mousePosition;
                timeOfLastMove = Time.time;
            }
        }
    
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.