Forum rules - please read before posting.

Hotspots not working on first run of game

edited February 21 in Technical Q&A

Hi, this is a really strange one and has only just started happening. On first play of the game, non of the hotspots work UNLESS my player’s hotspot detector is colliding with two hotspots at the same time. We are just using this hotspot detection method, no mouse. On second play, they are all fine.

The only differences between first and second play are:
On first play, the game isn't loaded.
On second play, some of an action list is skipped, which are just some play sounds, some NPC dialogue and some character animation.

Anyone got any ideas?

Comments

  • AC and Unity versions?

    I'm not clear on how you're defining "first" and "second" plays. Are you talking about closing the app and re-running it, or are you keeping track of a player's progress via some variable?

    I also don't understand what you mean by the game not being loaded on the first play. Can you elaborate on this exactly?

    I'll also need to see screenshots of your Settings Manager, full Player Inspector, and sample Hotspots that work vs don't work at runtime.

  • Unity version - 2018.4.9f1 Switch
    AC version - 1.69.3

    First play as in the first time you run the app after clearing all player prefs. Second play as in you turn off the app and then turn it back on again. I'm doing this in Unity editor, not on a build, so the process is: Clear player prefs, press play => hotspots don't work. Wait until autosave occurs and then press stop, press play, hotspots work.

    The game isn't loaded on the first play because there is no save file to load. Then, after the first play, if you allow it to get to the first autosave point before turning off and on again, there is a save file to load so it loads it.

    To simplify the situation, I've made it so on first and subsequent plays, the exact same process is followed apart from the fact it loads the save file on subsequent plays and so then calls the 'OnLoad' cutscene, which just calls the start sequence action list asset.

    I can make the hotspots work on first play by making a massive hotspot that covers the player and the other hotspots. Obviously this is not a good fix, I'm just including this information in case it helps narrow down what might be happening.

    It is really strange because it has only just started doing this very recently. Also I don't know if this is related, but I've also had some issues with action list assets not being found near the start of the game (I get a null exception message when another action list tries to run them). They are sometimes found, but not always. I've just fixed it by moving the offenders into the scene, but it's odd and maybe connected.

    Screenshots below and video of the process with the inactive and active hotspot.
    https://drive.google.com/file/d/1kAO_k2qjLzpVkV56lxEnqIO6AC3FGUK8/view?usp=sharing

    https://drive.google.com/file/d/1NRWFB_FCGUEJzMi77PH3Zg0-FWlXT9st/view?usp=sharing

  • Thanks for the details, though I'll still need to see screens comparing the state of Hotspots when they work vs don't.

    PlayerPrefs will be created when a game is first run regardless of saving. Does the issue remain the same if you avoid auto-saving and/or avoid loading the autosave? If you can, try to remove as many elements from the initial game logic (OnStart / OnLoad) to see which part exactly is causing the issue.

    It's not clear if the issue is to do with with the Hotspots themselves, or with the Player. I notice you have some custom scripting attached to your Player. As a test, temporarily replace him with Tin Pot, the demo game's Player. He can be found in /Assets/AdventureCreator/Demo/Resources. He's equipped to work with "Player Vicinity" detection - does he have the same issue?

    Also I don't know if this is related, but I've also had some issues with action list assets not being found near the start of the game (I get a null exception message when another action list tries to run them).

    Related or not, if there's an issue here it should be looked into. Are you able to reliably recreate this, and what is the full error message that appears in the Console?

  • Yeah of course it needs looking into. It's on the list of many. It just felt related, which is why I mentioned it.

    FYI, the hotspot problem was the cursor again. I was disabling it because it was causing problems. (Engine -> Manage systems -> Cursor: Disabled). StateHandler doesn't update some general hotspot bools if the cursor is disabled.

    We don't use the cursor in normal gameplay and only on a few rare menus. During normal gameplay, locking the cursor just fixes it in the centre of the screen and hides it but doesn't deactivate it. When not in normal gameplay, locking the cursor only hides it but doesn't actually lock it.

    I've fixed it by just locking the cursor instead of locking and disabling and when locked, forcing down to the bottom left corner and making this happen in all game states.

    It would be really useful to have an option to disable the cursor (turn off completely) without it affecting anything else.

  • Yeah of course it needs looking into. It's on the list of many.

    I mean, I'd need to look into it. If you can share more details of the specific message, and steps to recreate, then I can investigate this further.

    It would be really useful to have an option to disable the cursor (turn off completely) without it affecting anything else.

    The Action disables AC's Cursor "system", not the cursor itself - so if you rely on e.g. a Hardware cursor it'll still be displayed. I agree that this should cause conflict with Hotspots in the way you've experienced, though.

    If you open up StateHandler and insert the following into line 145, does that allow the cursor to be disabled without giving your Hotspots issues?

    }{
    
  • edited March 3

    'Related or not, if there's an issue here it should be looked into. Are you able to reliably recreate this, and what is the full error message that appears in the Console?'

    It hadn't happened for a while, but it has just happened again. The full console error is below. It happened on an action list that normally runs fine and was on third restart (in Unity editor, stopping and playing the scene without clearing player prefs). The action list that was running that contains the action 'ActionList: Run' is correctly instantiated in the scene and it running, but the action list that it then tries to run has not been instantiated. The action 'ActionList: Run' is highlighted in green at this point and the game is stuck there.

    It's like the asset (It's an asset not in scene) is no longer in the runtime action list list?

    I've repeated and it always happens on the third time.

    NullReferenceException: Object reference not set to an instance of an object
    AC.ActionListManager.EndList (AC.ActiveList activeList) (at Assets/AdventureCreator/Scripts/Managers/ActionListManager.cs:469)
    AC.ActionListAssetManager.EndAssetList (AC.ActionListAsset asset, AC.Action _action, System.Boolean forceEndAll) (at Assets/AdventureCreator/Scripts/Managers/ActionListAssetManager.cs:157)
    AC.ActionRunActionList.Run () (at Assets/AdventureCreator/Scripts/Actions/ActionRunActionList.cs:147)
    AC.ActionList+d__33.MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:370)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
    UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
    AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:320)
    AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:552)
    AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:470)
    AC.d__33:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:439)
    UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
    AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:320)
    AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:552)
    AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:470)
    AC.d__33:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:439)
    UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
    AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:320)
    AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:552)
    AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:470)
    AC.d__33:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:439)
    UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
    AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:320)
    AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:552)
    AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:470)
    AC.d__33:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:439)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

  • FYI - Inserting }{ into line 145 of the cursor is incorrect code. Instead I moved the } from 170 to 142, which I think has the effect that you meant? It worked anyway. The hotspots now work even when the cursor has been disabled, thank you. That problem is now sorted.

  • More information:

    In ActionListManager, I put a breakpoint at line 469 and found that the null exception is thrown because activeList.actionList is null but activeList.actionListAsset is not null and the if condition checks that activeList.actionListAsset is not null but does not check activeList.actionList is not null before using it in the if conditions.

    The line is:
    if (activeList.actionListAsset != null && activeList.actionList.actionListType == ActionListType.PauseGameplay && !activeList.actionList.unfreezePauseMenus && KickStarter.playerMenus.ArePauseMenusOn (null))

    If I change the line to this:

    if (activeList.actionListAsset != null && activeList.actionListAsset.actionListType == ActionListType.PauseGameplay && !activeList.actionListAsset.unfreezePauseMenus && KickStarter.playerMenus.ArePauseMenusOn (null))

    or to this:

    if (activeList.actionList != null && activeList.actionList.actionListType == ActionListType.PauseGameplay && !activeList.actionList.unfreezePauseMenus && KickStarter.playerMenus.ArePauseMenusOn (null))

    Then it gets past the 'EndList' method, then throws this warning: 'Ended asset InitPlayer, but ActiveList data is retained.' from line 161 in ActionListAssetManager and then the code has a second attempt at ending the list and this time both activeList.actionList and activeList.actionListAsset are not null and everything seems to be fine. The actions of the offending action list happen as expected and the game carries on.

    Was this a typo or is it supposed to read like that and I've done something horrendously wrong somewhere that I shouldn't be and this has caught it?

  • Full console from the warning is:
    Ended asset InitPlayer, but ActiveList data is retained.

    -> AC debug logger
    UnityEngine.Debug:LogWarning(Object, Object)
    AC.ACDebug:LogWarning(Object, Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:25)
    AC.ActionListAssetManager:EndAssetList(ActionListAsset, Action, Boolean) (at Assets/AdventureCreator/Scripts/Managers/ActionListAssetManager.cs:161)
    AC.ActionRunActionList:Run() (at Assets/AdventureCreator/Scripts/Actions/ActionRunActionList.cs:147)
    AC.d__33:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:370)
    UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
    AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:320)
    AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:552)
    AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:470)
    AC.d__33:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:439)
    UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
    AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:320)
    AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:552)
    AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:470)
    AC.d__33:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:439)
    UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
    AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:320)
    AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:552)
    AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:470)
    AC.d__33:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:439)
    UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
    AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:320)
    AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:552)
    AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:470)
    AC.d__33:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:439)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

  • edited March 4

    Inserting }{ into line 145 of the cursor is incorrect code.

    I forgot you're using an old release.

    It hadn't happened for a while, but it has just happened again.

    Thanks for the details, but before I can suggest any code changes I'll need to experience the issue myself. Please share steps on how to create the issue - I'm assuming this requires a pair of ActionLists (one to call the other), but I'll need to be clear on the exact details.

    I would recommend, however, trying this out in the latest release - even if only in a backup/duplicate project.

  • On the third restart (i.e. second time the save is loaded and OnLoad cutscene is called) the route is:

    OnLoad Cutscene ActionList runs the actionListAsset 'StartSequence'.
    StartSequence runs the actionListAsset 'InitPlayer'.

    Init player is the one that gets lost temporarily.

  • FYI - We have just upgraded to your newest version and the problem is unchanged. I have left my tweak in for now, which seems to have fixed it, but feels like I am bypassing a deeper issue somewhere, or masking a user error (ie me :D )

  • edited March 5

    Thanks for the details, but what are the properties of the Action and InitPlayer asset? I need to be really clear on the details as these all affect the background processes. Screenshots would be best.

    I also need to know what state the "InitPlayer" asset is in at the time of loading - is it still running from the last time when you re-load? That this occurs on the "third run" suggests that its time-dependent.

    I really need to be clear on the exact steps here - it's the small details that matter with an issue like this.

  • When I said 're-load' I mean I stop the whole game in editor by pressing stop and then press play again, so nothing is still running. The whole programme is starting from the beginning. The only difference is the save file in playerprefs. The first time after clearing playerPrefs, it is empty. From the second time onwards, it is not empty because things have been saved to player prefs. The problem happens from the third time onwards.

    InitPlayer is an asset file in resources. It is not still running because I am closing the programme down and restarting. It is the first time it is called after restarting.

    Attached is a link to the properties of the OnLoad cutscene and the two action list asset files.

    https://drive.google.com/open?id=1LR63JGym2BGTuD7mIjcPVhN9GDCQXcrS

  • I still cannot recreate such behaviour. Is this unique to Switch, or is it also occuring on desktop?

    I'm failing to see what relation the PlayerPrefs has to do with this. It may be linked to something that's in the InitPlayer's Actions, but I have no details of those.

    I think it will be best for you to create a test .unitypackage for me. If you can get this to occur in a fresh scene, create a .unitypackage of it, the two ActionList files, your game's Managers, PM it over to me and I'll try it out.

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!