Forum rules - please read before posting.

UFPS 2 Menu and player movement issue

TimTim
edited April 2020 in Technical Q&A

Hi Folks,

I’ve been doing some testing with Unity 2019.3.7f1, Adventure creator 1.70.4 and UFPS 2 and wondered if I have everything setup correctly. I have my player setup and working using the AdventureCreatorControllerHandler.cs

I seem to have a problem with the cursor not unlocking properly when opening a menu and player movement not being disabled, although it does slow down. I’ve had a scout round here, the Opsive forums and discord but can’t seem to find a solution.

Here is what happening:

I’ve assigned the letter ‘m’ within Unity’s Input Manager to call the menu.

Here are the various settings:

Interface settings

Global cursor settings

Main Cursor Settings

Global Menu Settings

MobileHome Menu Settings

When I call the menu it displays fine and the cursor appears. However, the cursor is still locked and the player can move. If I click 'm' on the keyboard again to close the menu, the menu doesn’t disappear but the cursor does.

I have assigned an action list when the menu is turned on which runs Engine: Manage systems which enable the cursor and the menus and an opposite action list for when the menu turns off:

If I assign the 'escape' key to activate the menu, both the AC and system cursor appear and I can interact with the menu but player movement is not disabled.

Interesting, I’ve noticed UFPS has some cursor settings on its Unity Input Component: Disable Cursor and Enable Cursor With Escape:

These seem to be ignored though as pressing escape still brings up the system cursor.

Apologies for the long post but I'm trying to cover all the bases that I can think of, is there anything I'm obviously doing wrong here?

Cheers,
Tim

Comments

  • edited April 2020

    Given UFPS's own Unity Input component, it's likely that there is a conflict in which both AC and UFPS are trying to control the cursor.

    It may also be that there's an issue with AC - or some configuration is wrong. Therefore, the best thing to do first would be to temporarly get thing working with AC alone - and leave UFPS out of the way for the moment.

    Create a new test scene, and drag in the Demo game's Player prefab, Tin Pot (from /AdventureCreator/Demo/Resources). He's also equipped to work in first-person, and will override the one in the Settings Manager if present in the scene itself.

    Do things then work as intended? Do note that the "Cursor" field in the Engine: Manage systems Action refers to AC's cursor system as a whole. While this may be necessary for integration with UFPS, it should not be necessary to disable this system when just using AC alone, since it will be hidden anyway when locked.

    I'm not sure why the Menu wouldn't turn off - could it be that the cursor is re-disabling as a result of the Unity Input component, and not the MobileHomeOff ActionList? You can check this by inserting an ActionList: Comment Action into the list to have it output a message to the Console that you can look out for.

    With regards to player movmement, AC's movement locks are an AC property so will only affect a Player that AC has control over. However, you should be able to have UFPS account for this also with the following inserted into the integration script's Update function:

    if (KickStarter.stateHandler.IsInGameplay ())
    {
        if (KickStarter.playerInput.CanDirectControlPlayer ())
        {
            EventHandler.ExecuteEvent <bool> (gameObject, "OnEnableGameplayInput", true);
            player.motionControl = MotionControl.Manual;
        }
        else
        {
            EventHandler.ExecuteEvent <bool> (gameObject, "OnEnableGameplayInput", false);
            player.motionControl = MotionControl.Automatic;
        }
    }
    
  • Hi Chris,

    Thanks so much for the quick reply and your suggestions, here is what I have so far:

    Clean scene

    I created a clean new test scene (with folders) and dragged in Tin pot but unfortunately, the problem with the cursor locking was still present. I also tried the simple player that the player wizard sets up, same problem :-/

    Menu not turning off

    I removed the system Engine: Manage systems actions from the action lists that run when the menu is turned on and off and that looks to have solved the menu staying put on screen – thank you 😊

    Disabling UFPS player movement

    The additional code added to the into the integration script's Update function seems to have fixed the problem with the player not staying put - thank you 😊

    So, it must be something going on with my project somewhere. My next step was to setup a clean project with just AC and setup a player again and step my through the menu setup again. All the AC menus worked and I decided to setup a simple Unity UI in scene, this all worked as expected so it had to be something to do with my original project settings!

    With UFPS having its own Input component, I wondered if was related to the system cursor as you mentioned so decided to _uncheck _Always shows system cursor in Editor while keeping Lock system cursor when locking AC cursor ticked.

    I think, that may have done it. I’ve run out of time today but I’ll keep testing and reporting back. Hopefully I’m on the right track.

    Thanks again for the pointers and code.

    Cheers,
    Tim

  • I created a clean new test scene (with folders) and dragged in Tin pot but unfortunately, the problem with the cursor locking was still present.

    Is this still the case after removing the Engine: Manage systems Action?

  • Is this still the case after removing the Engine: Manage systems Action?

    Sorry for the delay Chris. Yes, it seemed to be but I'll give it another shot to be sure and report back. I was testing a few things at the same time and may have got muddled.

    I also noted that with the addition of the code to disable the player when activating a menu, the console is spammed with:

    "Attempting to move a first-person Player in Root Motion - uncheck 'Apply Root Motion' in the Animator to unconstrain movement."

    The UFPS animator is handled by script, I thought it maybe related to the head sway that UFPS seems to ship with, the Shake speed variable, but setting this to zero still results in the console message.

  • EDIT: Chris, just to confirm, removing **the **Engine: Manage systems Action does indeed **FIX **the problem with the cursor locking with Tin pot.

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.