Forum rules - please read before posting.

Send Message: RunUseInteraction very slow

So I have a Door prefab, that I instantiate multiples of at runtime procedurally, that each have a Hotspot.
This Hotspot uses an ActionList asset file as the source in the Hotspot. There are two interactions on it - Open_Door, Close_Door. Both of those Interactions call their respective ActionListAsset.

Open_Door is enabled, Close_Door is disabled. Open_Door, upon completion, will activate Close_Door and disable Open_Door.

These use the Hotspot parameter (Door) which is on the Door object that needs to open.

I need to interact (Use) the Hotspot via Playmaker.

This works as expected when I use either Send Message (RunUseInteraction) or Call Method (RunUseInteraction) on the Hotspot of whatever instantiated prefab I'm interacting with in game.

The problem is there is a 1 second stutter in the game whenever I do this. I was able to pinpoint it to this call.

Is there any more optimized way of doing this so there is no delay?

Comments

  • edited November 2018

    Calling the method directly will be faster than SendMessage. At what point is the delay occuring - before or after RunUseInteraction is invoked?

    There should be no difference in timing between running that directly and interacting with the Hotspot via AC normally. Bear in mind that it will account for the "Player Action" fields defined in the Hotspot, so it'll still wait for the Player to e.g. face the Hotspot if that's what you've set.

    If need be, you could programatically apply the Hotspot parameter and run the ActionList asset directly - but I can't see why there'd be a delay on the AC side of things.

    Unity and AC version numbers?

  • mekmek
    edited November 2018

    Hmm...
    I'm using Unity 2017.4.12f1 and AC v1.65.1

    The delay is occurring at the exact moment RunUseInteraction is invoked. Same lag whether I use Call Method or Send Message. My UI flickers once and my movement lags for a second when this happens.

    Here is the Action List that is being run:

    This is the Playmaker event it calls within the ActionList:

    Makes me wonder if perhaps the issue isn't the invoking, but instead the ActionList itself.

    Does anything in those screenshots look particularly processing intensive?

    Thanks!

  • mekmek
    edited November 2018

    EDIT: I replaced the entire ActionList with just an Engine: Wait (0) and it still has the lag. So its actually nothing to do with the ActionList itself. It happens as soon as you Interact with the Hotspot (both in Playmaker code and just using AC's regular mouse-click interact).

    Could it be an issue with this being a prefab that is procedurally instantiated and there are many of them in-scene? Its almost like it is checking every door at the same time or something.

    This is what I put on the Door prefab:

    After I generate all the doors in the map on start up, I invoke "FixIDs" in "FixConstantIDs" and do not retain the Constant ID in the prefab. I have also tried various combinations of not using that method, retaining ID, etc. and it didn't have any effect.

  • edited November 2018

    Could it be an issue with this being a prefab that is procedurally instantiated and there are many of them in-scene?

    There'd be an easy way to check that - just remove all but one from the scene and test it out.

    Use the Profiler to detect lag or frame-rate dips, and share some details on how you're actually invoking RunUseInteraction, too. There's also nothing in AC's code named FixIDs or FixConstantIDs, so I don't know what you're referring too, there.

  • mekmek
    edited November 2018

    There'd be an easy way to check that - just remove all but one from the scene and test it out.

    Just tried this - looks like multiple prefabs wasn't the issue.
    After profiling, seems like Playmaker is to blame:

    Full size: https://i.gyazo.com/6b5a27541a43d39c6b4fb9f357749f17.png

    Looks like Playmaker had Debug logging on and it was getting flooded. Was able to get rid of that issue now. Even with that gone, I still get this strange UI flicker every time the door is open but I realize this isn't due to AC. Thanks for helping me identify that!

    There's also nothing in AC's code named FixIDs or FixConstantIDs, so I don't know what you're referring too, there.

    Oops, I mean't "CheckForDuplicateIDs" as referenced here: http://pasteall.org/1142698/csharp

  • mekmek
    edited November 2018

    One thing to note is that the scene generates a lot of AssetList Prefabs during runtime. Looks like it generates one for every door it opens/closes. This doesn't seem correct - shouldn't it destroy what it creates or always use just one?

  • mekmek
    edited November 2018

    Spoke too soon - it looks like I might have found the spike coming from RunUseInteraction?

    Full size details: https://gyazo.com/dc14ac1fd7e4760db3e0b92818afb78e

    Here is the actual Profiler log:
    https://drive.google.com/open?id=1Q7ObSJ6_5VXmFkVkD7qXBvLkOl3T7jZ4

    Does that provide any potential insights?
    Greatly appreciated!

  • The instance of an ActionList asset should remove itself automatically from the Hierarchy once it's completed. Multiple instances should only spawn if Can run multiple instances? is checked in its Inspector.

    If you run the ActionList asset manually via the Run now button in it's Inspector at runtime, does it persist or disappear as it should? Try also enabling the AC Status window via the bottom of the Settings Manager - does that indicate the all these instances are actually running?

    I'm confused by the Profiler because the MainCamera's ShowScene method should not be called by anything but itself - and even then only when a new scene loads. Have you modified AC's code? Again, I need to see details of how exactly you're triggering ACs functions via Playmaker.

  • mekmek
    edited December 2018

    Hi Chris -

    I actually don't have "Can run multiple instances' checked:

    Full size: https://i.gyazo.com/c38c6e055783ca48ee31b8d3d6416792.png

    Could anything else be triggering that? I've noticed it doesn't leave multiple instances persisting every time, only sometimes.

    When I manually use Run Now on the ActionList assets during runtime, it seems to disappear as it should, most of the time. It looks like occasionally it leaves one persisting, though.

    I have enabled the AC Status Window, which doesn't indicate anything unusual, yet here is an example of an ActionList asset persisting (Door_Open):

    Full size: https://i.gyazo.com/f3d89e414579e2c8e815759b3afb1624.png

    From what I can tell, it looks like the AC Status Window doesn't recognize the instance even though it is visible in the runtime hierarchy as shown above?

    As for the Profiler, I haven't modified any AC code, but I do use UFPS based on your integration tutorial. Could that be affecting it somehow?

    I am triggering AC's RunUseInteraction by calling the method (using the Call Method action) on the particular door's Hotspot component:

    Full size: https://i.gyazo.com/fd1abdf3771ff49eb1df9935a8109c13.png

    Full size: https://i.gyazo.com/d502bca5d8b2b2ebbfba097f1363c19c.png

    Since these doors are procedurally generated prefabs, I can't just call Interact on the ActionList asset.

  • After I finished sharing the above images, I just noticed that the AssetList Assets default to "Pause Gameplay" when running. It seems likely that this is the source of the game hiccups!
    If the game is pausing momentarily to complete the actions, of course there will be a stutter. Woohoo!! :)

    I'm still not sure why multiple assetlist actions get instantiated and not destroyed in the hierarchy though, which may be a different issue.

  • Yes, it is. And the first screenshot you posted is the complete list?

    Try opening an errant instance in the ActionList Editor - are any of the Actions highlighted green to indicate they're currently running?

  • That is the complete list.

    Sorry, had to wait until I ran the game a few more times before the multiple instances appeared again.

    When opening the errant instance in the ActionList Editor, none of the actions are highlighted:

    Full size: https://i.gyazo.com/2807592b11d97b14587e0a3f2993d8df.png

    Here the hierarchy shows multiple instances:

    Full size: https://i.gyazo.com/10a8a6049b1e2bf0a44cfe94b87b318b.png

  • Just checking to see if you've had a chance to take a look and if anything unusual stands out that would cause multiple AssetLists to spawn in the hierarchy and not get destroyed.

  • I have - but turned up nothing yet, I'm afraid.

    If you'd like to PM me a project / unitypackage file along with steps to reproduce this, I'll see what can be done.

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.