Forum rules - please read before posting.

Check Cursor Lock/Visibility

Hi, I'm facing a problem here that I wasn't seeing it coming when I first designed my game.

So, I'm using the ToggleCursor input feature.

But, I haven't figured how to track the cursor's state with a simple action, so everytime I use the input ToggleCursor, I also run an Active Input to change the value in a boolean global variable, and thats what I've been keeping track.

The player is able to switch between ThirdPerson and Fixed Angle as he goes, and may ToggleCursor anytime, to interact with hotspots.

But its getting complicated as more features are added, I know that it could get a lot simpler if I could just directly check if the cursor is constrained.

I am needing to check if the cursor is either locked or unlocked, to run specific Actions to either state.

Please help me

Comments

  • AC.SaveData.mainData.toggleCursorState is probably what you're looking for - but I think you're going to have to do a bit of custom scripting to have access to it in action lists.

  • edited April 2017
    I had a similar situation (but different, I needed to change lock state depending on active UI).Here's the script. You can use it as an example or use it as it is. The script also closes menus on startup that shouldn't be on right away, you comment CloseMenus(); if you don't want that to happen. 

    Mind you, the script is a little old by now, I hope there's no errors (since there's been so many updates since).

  • The toggleCursorState is only recorded when saving games.

    You can read if the cursor is currently locked with:

    AC.KickStarter.playerInput.IsCursorLocked ();

    However, the cursor also unlocks when in pause menus - and this is separate from the "toggled" state.  If you want to set the in-game cursor's state to the value of a variable, you can use:

    AC.KickStarter.playerInput.SetInGameCursorState (myStateBoolValue);

    Currently the internal value this script uses to record this state (PlayerInput's toggleCursorOn boolean) is private.  You can amend the script to make this public if you wish, and I shall provide a function to read this in the next update.
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.