Forum rules - please read before posting.

Cursor lock and unlock

Hi,

I am adapting a First Person Touchscreen game for PC and have some issues with cursor locking and unlocking.

At start of game, cursor is locked in center and WASD for movement and mouse for turning works fine.
When I click on a certain hotspot (positioning the locked cursor on a Hotspot), an Action List (Run in Background) containing among other things a move to a CloseUp camera and "Change Movement method to: None". The cursor is unlocked and I can click on menu buttons etc. The hotspot is not disabled so if I click on it again, the same action list(s) are run but the cursor is then locked to the center.

I have traced this to ActionSystemLock.Run():

if (changeMovementMethod)
{
    KickStarter.playerInput.InitialiseCursorLock(newMovementMethod);
    KickStarter.settingsManager.movementMethod = newMovementMethod;
}

where it seems to toggle cursor even if movement method is the same?

It doesn't affect the touchscreen setup but for PC, the cursor needs to stay unlocked until i return to gameplay and an action list is run to Change movement method back to First Person.
I have a similar setup in multiple places and Action Lists so I would rather not enable/disable the Use: for all of them.

I'd also like to change the cursor texture depending on if it is locked or unlocked. Is there a built in way to do this?

The Unity UI cursor contains two parts: 1. An animation that only shows when hovering an inventory item over a hotspot (not applicable here) and 2. A raw image that is assigned by the Cursor Manager.

Settings and Cursor managers:
https://imgur.com/gW5xSDi

Unity 6000.2.14f1
AC 1.86.7

// Magnus

Comments

  • where it seems to toggle cursor even if movement method is the same?

    You're quite right. I've looked into this and it's safe to change that first line to:

    if (changeMovementMethod && KickStarter.settingsManager.movementMethod != newMovementMethod)
    

    I'd also like to change the cursor texture depending on if it is locked or unlocked. Is there a built in way to do this?

    Not currently, but it's a good suggestion. I'll add a new Animator parameter field for this in the Unity UI component, as well as make the above change, as part of 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.