Forum rules - please read before posting.

Cursor Movement

Hey all,

I've been away from AC/Unity for a month or so now however I've actually taken a 6 month sabbatical off work to travel and I'm using a lot of my new free time to give game development a proper go so I'm hoping I can get my project back up and running again!

I've overcome a few hurdles to get back into the swing of things however I'm pulling my hair out with one of them. My system cursor and the game cursor are two different animals and never move in unison. I currently have two screens setup (with the game window dragged into the second screen) however whenever I play the build in the editor that system cursor is free to roam around everywhere and because the game cursor doesn't move 1:1 with my system cursor I can end up clicking off the game window screen.

Even when my system cursor is inside the boundaries of the game window the game seems to acknowledge only where the system cursor is and not the game cursor which is very annoying when trying to click on something! The system cursor is hidden when it enters the game window boundary (as it should - I have software rendering enabled for the cursor) so although the game hides the system cursor it takes instruction from it rather than the game cursor.

I have tried building the game however the same problem persists? Any advice at all, this must be a simple fix and something I'll likely feel stupid about missing when the solution is found/given. Thanks in advance.

p.s. Unity 2017.1.1f1 and AC 1.59e


  • Does this issue persist in builds?  How about the Always show system cursor in Editor? setting?  This may be partway a Unity issue as it's been a source of frustration for me as well in non-AC projects.
  • Chris, sorry, I realised that I ended my statement about the problem persisting in builds with a question mark for some reason however I was stating that I had tried it in a test build and the problem did indeed still persist (apologies for the confusion).

    The Always show system cursor in Editor? was originally unchecked, I've tried checking it however the same problem persists.

    One thing that I have noticed that is very weird is that I have a UI 'button' that floats around that you have to click on, this then runs an interaction and moves the camera to a different location so that the player can investigate further (this new area then has a hotspot to click on). The floating UI button responds to the system cursor's location and not the in-game software cursor however the hotspot later only responds to the in-game software cursor location and not the system cursor.

    At first this issue was affecting my testing however with the build not working either it obviously affects the final product too. Hopefully if it is a Unity issue then the problem will be more widespread and therefore a solution must be out there. I'll go back to scouring the Unity forums in the meantime.
  • Unity UI-based Menus rely on the system, cursor, while AC ones rely on AC's own - but these ought to be the same thing in most cases.  Please post a shot of your Settings and Cursor Managers so I can see better what's going on.
  • @ChrisIceBox

    Yeah I don't believe I ran into this problem before with previous AC projects. As an aside the pause menu also only reacts to the system cursor which again not only is separated from the in-game AC cursor however no cursor shows up at all when in the pause menu?

    Link below shows my settings manager and cursor manager (quick note that my game switches between two different hotspot detection methods, between Mouse Over and Player Vicinity) I change this at runtime via custom scripting which works perfectly. So the image in the below link shows both states of my settings manager as well as the cursor manager as requested.

    I probably should've mentioned the switching between hotspot methods before however I do not believe I'm changing anything that would result in the issues I'm experiencing? However just in case below is the code that I am running when I switch to Mouse Over:

    AC.KickStarter.settingsManager.hotspotDetection = HotspotDetection.MouseOver;
    AC.KickStarter.settingsManager.interactionMethod = AC_InteractionMethod.ChooseHotspotThenInteraction;
    AC.KickStarter.settingsManager.selectInteractions = SelectInteractions.CyclingCursorAndClickingHotspot;
    AC.KickStarter.settingsManager.hotspotIconDisplay = HotspotIconDisplay.Never;
    AC.PlayerMenus.GetMenuWithName ("Interaction").appearType = AppearType.OnInteraction;
    AC.PlayerMenus.GetMenuWithName ("Interaction").uiPositionType = UIPositionType.AppearAtCursorAndFreeze;
    AC.KickStarter.settingsManager.cancelInteractions = CancelInteractions.ClickOffMenu;
    AC.GlobalVariables.SetBooleanValue (0, false);
    AC.KickStarter.playerInput.SetInGameCursorState (false);
    AC.KickStarter.playerInput.SetFreeAimLock (true);
    AC.KickStarter.playerInput.SetUpLock (true);
    AC.KickStarter.playerInput.SetDownLock (true);
    AC.KickStarter.playerInput.SetRightLock (true);
    AC.KickStarter.playerInput.SetLeftLock (true);

    And then here for when I switch to Player Vicinity it's pretty much the reverse of the above (I couldn't paste this one because it would exceed the post length. I do apologise, I wrote the above code months ago and as I'm a novice I can;t be sure whether I've changed something I shouldn't. From re-reading I do mess with the cursor lock however that is to simply lock the cursor in the centre of the screen when hotspot detection is Player Vicinity (so 3rd person movement is possible) and then I unlock it and enable the cursor when Mouse Over detection is enabled (so a sort of investigation mode where the player is stationary and the player moves the cursor freely to interact with items.
  • Thanks.  And on what platform are you building with/to?

    Even if it seems unlikely to affect, it's important to temporarily remove any custom code so that it can be ruled out completely.  Do the same issues occur when you switch to either of the demo games?
  • Your "Input method" is set to "Keyboard Or Controller".  When this is set, the cursor is moved through input axes and not by the system cursor's actual position.  If you want to use the system cursor, set it to "Mouse And Keyboard".
  • @ChrisIceBox

    Ah I see...I've selected Keyboard or Controller though so that the player can control using either Keyboard+Mouse or a Controller (if controller then the game cursor is moved using the Right Analog Stick) so mechanically I can't go to Mouse and Keyboard as this will remove the controller option.

    Have I therefore designed my way into a corner?
  • You'll just have to dynamically alter the field's value based on the user's choice, which I'm guessing would be in the Options menu.

    Any Manager field's API reference can be attained by right-clicking it's label.  In the case of the Input method, it's:


    You can change this to InputMethod.MouseAndKeyboard or InputMethod.KeyboardOrController accordingly.

    This can be incorporated into a custom Action if you want to easily set it as part of regular AC ActionLists.

    Bear in mind that as this actually affects the asset file, changes may survive restarting the game - so you may want to run this code to set it to a default value in your game's ActionList on start game, which you can define in your Settings Manager.

    For details on how to incorporate it into a custom option, see the "Options data" chapter in the Manual.
  • @ChrisIceBox

    Ah ok....the way I currently have it I don't ask the player to select an option (they can just control using mouse/keyboard or controller in the fly) however due to the above issues it does make a lot more sense to control this more rigidly by asking the player to actually specify in the options what control method they will be choosing.

    From what I understand this should help me out loads with my issue - I'll test it later tonight but in the meantime I just wanted to say thanks again, I';ve said it numerous times and you must hear it loads of times but your support on this forum really is the best thing about this asset (which is saying a lot considering how awesome the asset is)!

    .....although the solution you gave should've been something I got to on my own - didn't require any complex coding, it was a logical solution that never even entered my mind!
  • @ChrisIceBox

    Just a quick update to say thanks again, I've got this working perfectly and actually highlighted another issue that I've now resolved that I only could've solved thanks to your suggestion regarding the option file and the player specifying what control method they'll be using.

    This additional issue I had was when it came to menus, because I kept the 'KeyboardOrController' as the default before I'd have no way of knowing whether the player would use a mouse, controller or keyboard to go through the menus. So now I've setup the aforementioned option in the options menu for the player to specify their controlling method, if mouse not only does the input method get changed to Mouse and Keyboard but I clear all the First Selected Element strings from each of the menus. However if the player chooses controller then not only does the input method change to Keyboard or Controller but I specify each string of each menu under the First Selected Element so that the player can then navigate the menus with the controller. I did initially just default all menus to select an element however I found this off-putting when using a mouse because you can hover over another element and have two different elements highlighted at the same time (the first selected element as well as the one the mouse is hovered over - there is likely a solution to this however I quite like the solution I've implemented).

    Sorry for the long winded post but thanks again for the help and advice!
  • No problem, thanks for the details.

    Actually, you bring up an important issue in that some of the options that appear in the Menu Manager when using Keyboard And Controller input (such as Directly-navigate Menus when paused?) have an effect regardless of whether or not the option is visible.

    I'll have to look into it more thoroughly but I suspect this is a bug, as it doesn't sound right that you should have to clean all the First Selected Element fields if the Menu hasn't been configured to be directly navigated.
  • So even though that option gets hidden when the control input is set to Mouse and Keyboard that it still has an effect - it is currently ticked (when the input method is Keyboard or Controller) so when it gets hidden when Mouse and Keyboard is selected the ticked option is still having an effect.

    So it would be easier for me to change just that option when control schemes are changed as opposed to current way I'm doing with the clearing of the element fields. Although you seem to suggest this is a bug? Everything is currently working perfectly as I need it to so all is good at the moment :)
  • It is a kind of a bug, but not in the way I was first thinking.  The "direct-control" options should show regardless of the Input method, because they still affect UI-based Menus.  However, any change regarding that won't affect your current set up, so don't worry about it.
  • @ChrisIceBox

    I should probably setup a new discussion however I wasn't sure (the issue I'm having was part of the secondary issue highlighted in this topic and not the one mentioned in the title).

    Either way I seem to be struggling with the direct navigation of the menus. Whilst mouse controlled everything is obviously fine, mouse is used to navigate menus however if the player is using a controller then as mentioned above I change the control method to Keyboard or Controller as well as specifying the First Selected Element for each applicable menu. This works fine for the menus that pause gameplay as well as the conversations menu because of the options in the Menu-Manager Directly-navigate Menus when paused/during Conversations? however the menus that don't pause gameplay (Inventory and a Laptop/Tablet menu I created) the direct navigation doesn't work.

    I tried setting these menus to pause when enabled and direct navigation works (but whilst paused it breaks the functionality of said menus). So firstly what are you changing when then above Directly-navigate Menus when paused/during Conversations? are checked? I was hoping that I'd be able to create a custom script and simply change the Inventory and Laptop/Tablet menus to be directly navigated in the same way you've done with the aforementioned checkbox option. I looked at copying the API however I believe that simply enables me to toggle these checks on/off and doesn't actually help me in the way I want. As always thanks in advance for the help!
  • edited October 2017
    AC checks a given Menu against the current gameState (Paused, Conversation, Normal, etc) to see if it's appropriate to allow direct-control.

    However, if the Input method is set to Keyboard And Controller, then an additional option to allow in-game (i.e. gameplay) menus appears in the Engine: Manage systems Action.  This option is in an Action, as opposed to the Menu Manager like the others, because it's more likely you'd need to change it at runtime.
  • edited October 2017

    Original post below however I have a minor update - Direct Control now seems to work however only if I use the system cursor with the mouse to click on one of the inventory items or shift left/right buttons first. I've setup the First selected element correctly and as mentioned before this works fine when I enable the menu to pause gameplay when opened and allow direct-navigation when menu is paused so this side of things is setup correctly however as mentioned for some reason it's not working during gameplay (but does work if I first use the mouse to click on the inventory with the system cursor)? I'm going to test a quick build of the game to see what happens there.

    Thanks, found it (never noticed that additional option before). It doesn't however seem to work though, I've tried running this action when the Inventory menu opens however it doesn't seem to allow direct control (actually technically I enable control of in-game menus just before the menu is opened and then disable again once closed),

    I've tried again making the Inventory pause when opened and with this option ticked direct control is properly given however as mentioned before because it pauses gameplay it then takes away the functionality of the menu. So everything else I'm doing seems to allow for direct control when the menu is paused (because the option to direct-navigate menus is ticked in the menu manager) so there surely must be some function I can call that will allow me to direct control for the inventory despite it not being paused or being the conversations menu (or is that exactly what the aforementioned action you pointed me towards is supposed to be calling)?
  • Is this the default Inventory Menu / UI Prefab?  Please post a shot of the Menus' properties from the Manager.  The Menu Manager also has a Disable mouse when keyboard-controlling Unity UI Menus? option - what's the state of that?

    When and how exactly are you calling the Engine: Manage systems Action?  Please provide a shot of that too if possible.
  • @ChrisIceBox

    Sorry mate, must always be difficult trying to get to the bottom of some of these issues with no screenshots lol. Below is a link to the properties of the Inventory menu, I've not changed this at all (well except for specifying a RectTransform boundary however I tried clearing that and trying but no luck so I don't believe this is affecting things.

    Inventory Menu Properties

    I've also tried checking and unchecking the Disable mouse when keyboard-controlling Unity UI Menus? option and in both states I still have the weird issue (whether checked or unchecked I still have to use the system cursor to get onto the Inventory as mentioned above however the only difference being that when the option is checked the the mouse click doesn't actually 'activate' the inventory item, it only gets me onto the Inventory so I can directly-navigate). Hopefully that made sense?

    As for the Engine: Manage systems as mentioned I call this before opening the Inventory Menu - the appear type for the Inventory is Manual (apologies, this is the second difference from the default prefab. I have setup an Active Input in AC so that when the Inventory input button is pressed (I) it runs the action list that I've attached below. I did this so that I could have more control on when the Inventory can be opened/closed by checking a Global Variable as you can see below. Also attached is the Scene based action list that is called by the asset action list if the Inventory is available to be accessed or not.

    Action List - Active Input Toggle for Inventory  (Asset)

    Action List - InventoryTurnOn (Scene)

    You many notice a cutom action that I also call, it is something that worked great for me whilst using Mouse and Keyboard as I needed to change things slightly whilst the player uses the Inventory from the usual control scheme. I've tried by changing various parts of the below code as well as not calling it all but still no luck when  it comes to KeyboardOrController. And when calling the below, as mentioned, direct-navigation works fine if I enable the Inventory to pause when enabled so I'm sure it's not affecting it (however obviously you're the expert here so not my place to make that judgmenet! Also you can see the custom action being called in the above and the obvious question from you would be to check this hence why I've posted it). I do hope posting this snippet of code is ok? It is a custom action and doesn't show AC's code so should be fine however please let me know if you prefer I didn't post code in future.

    Custom Action - Called During Above InventoryTurnOn Action List
  • Thanks for the concern, but posting custom code is fine - just please do it in e.g. next time so that it can be copied easily.

    Correct me if I'm wrong, though, but it looks like the same code is running regardless of the variable's value.

    The Inventory Menu also shows that no first-selected element is defined - though I'm assuming this is because, as you said, you're setting this dynamically based on the user's option.

    I believe this issue is to do with the state of the game at the time the menu is opened.  For an in-game menu to be controllable, the game must be in "gameplay" state at the exact moment it's turned on.  If you're using ActionLists to turn it on, then they need their When running fields to be set to Run In Background.  I recreated the issue following your shots, but resolved the issue when making that change.
  • @ChrisIceBox

    YOU'RE MY HERO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    I've spent most of my weekend trying to find various different ways of overcoming this issue...changing the action lists to run in background worked a treat. So damn simple however I'd have never thought of doing this whatsoever!

    Yes the same code was run regardless of the variables value however I'd been tampering and testing so many options that I only realised afterwards that my latest changes meant that I was essentially testing a situation whereby the same values were being changed regardless of the bool being true or false (it was a long night lol).

    And yes as mentioned I dynamically call the first element selected at runtime (which worked for the paused and conversation menus so I knew that wasn't the issue). However now thanks to your advice it is now working absolutely perfectly for my inventory.

    You seriously have no idea how much more time you've now saved me (yet again) and how thankful I am of your continued support. Thanks again Chris, you're a legend!
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.