Forum rules - please read before posting.

Lost Cursor since latest update

Unity 2018.4.9f1 Switch
AC 1.70.4

I used to be able to turn the cursor on/off with Player: Constrain: Cursor Lock Disabled/Enabled.

Now, since updating AC, the cursor doesn't show up when unlocked. I found the part of the code by trial and error that's hiding it when it's unlocked which is line 124 in PlayerCursor.cs (showCursor = false;).

Have I inadvertently changed a setting and not noticed or is this because of the update and I now need to do something different?

Attached is a link to my cursor settings and normal settings. I've checked my normal settings and they are unchanged from before. I don't remember touching the cursor settings.

https://drive.google.com/open?id=1Nom8NSZOIZepf-2zcvpObimEUAGylZ87

https://drive.google.com/open?id=1dVh5eVhPJ7oCWG-zDsM5Mi2XAvGuvB2s

Comments

  • What version were you previously using?

    The line you're referring to hides the cursor when your menus are under direct control. At what moment exactly is the cursor hidden - during a Conversation, while paused? Enabling the "AC Status" box at the bottom of the Settings Manager will reveal the current "Game State" during this time.

    Let's see a shot of your Menu Manager's global properties, too.

  • AC version - 1.69.3 was previous version.

    Thanks, that led me to the problem. In Menu Manager, 'Direct navigate menus when paused' was checked. It must have somehow got itself checked in a git merge or the AC update.

    Some of our pause menus are directly navigated and some aren't so I have it unchecked there and then tweak your code in player input to make the cursor always lock in the bottom left corner if we tell it to in an action list by changing the line 'else if (KickStarter.stateHandler.IsInGameplay ())' to just 'else' at line 568 in playerInput so that it means locking the cursor in an action list works as expected wherever you are in the game.

    Thanks for the help.

  • You're better off changing the value dynamically when such Menus are turned on, rather than modifying the source code.

    Something like:

    using UnityEngine;
    using AC;
    
    public class DynamicDirectControl : MonoBehaviour
    {
    
        public string[] directControlPauseMenus;
    
        private void OnEnable () { EventManager.OnMenuTurnOn += OnMenuTurnOn; }
    
        private void OnDisable () { EventManager.OnMenuTurnOn -= OnMenuTurnOn; }
    
        private void OnMenuTurnOn (Menu menu, bool isInstant)
        {
            bool directControl = false;
            foreach (string directControlPauseMenu in directControlPauseMenus)
            {
                if (menu.title == directControlPauseMenu)
                {
                    directControl = true;
                }
            }
    
            KickStarter.menuManager.keyboardControlWhenPaused = directControl;
        }
    
    }
    
  • Nice bit of code, thanks.

    I think it's arguable what makes the project less fragile. Your way would add another type of thing for people to be aware of and my way doesn't, because I have had to tweak a couple of other lines of source code in other places anyway where is is unavoidable. But changing source code should, I agree, be avoided wherever possible.

    I noticed on the update that you had made the locked position a property, but then not made is possible for us to assign it to anything ourselves to be able to get the hidden but still active cursor out the way of the middle of the screen. Is this something you plan to add at some point?

  • You can override the cursor position to set the locked position to whatever you wish:

    using UnityEngine;
    using AC;
    
    public class LockedCursorOverride : MonoBehaviour
    {
    
        [SerializeField] private Vector2 lockedPosition;
    
        private void Start () { KickStarter.playerInput.InputMousePositionDelegate = CustomMousePosition; }
    
    
        private Vector2 CustomMousePosition (bool cursorIsLocked)
        {
            if (cursorIsLocked)
            {
                return lockedPosition;
            }
            return Input.mousePosition;
        }
    
    }
    

    See the Manual's "Remapping inputs" chapter for more on this topic.

  • Oh cool thanks for the change, very helpful

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.
Do NOT follow this link or you will be banned from the site!