Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

Passing Prefab Parameters between ActionLists

edited January 28 in Technical Q&A

Hi Chris

I'm currently trying to squash an intermittent but game-breaking bug, and in the process I've been trying to rationalise some of my larger, more complex ActionLists. Some of the larger ones are approaching 100 Actions, and have become unwieldy, both to follow, and to edit

A lot of my game involves interactions with NPCs, so I have, say, a generic "StopAndTalk" ActionList into which I pass two GameObject parameters, "ActorPrefab" (the Reference Scene Instance of the NPC) and "ActorMarker" (a Marker attached to the NPC, which the Player uses to navigate to them)

So far so good. If I process everything within that single ActionList, everything works as expected

BUT, if I try and pass the "ActorPrefab" parameter from the "StopAndTalk" ActionList into another ActionList, then I don't think that the called ActionList processes the Prefab as "Reference Scene Instance", but instead it assumes that it is a "Reference Prefab", and consequently doesn't process it correctly (or at least, doesn't process it in the way I WANT it to)

This means that I can't split my large ActionLists down into smaller, more digestible chunks, as I was hoping to be able to do

Is there any way round this, or do I have to find some other solution?

(I'm planning on eventually re-writing the whole project with a lot of this kind of stuff done in code, but I'd like to get the current ActionList-based version to at least a working state before I attempt that)

Comments

  • on reflection, i guess one solution would be for the top level ActionList to call a series of ActionLists (e.g. "StopActor", "TalkToActor", "ResetActorOnPath", etc), each of which gets passed the "ActorPrefab" and "ActorMarker" parameters. that way i could specify "Reference Scene Instance" for each parameter in each called ActionList

    it's a bit clunky, but i think it would work

    probably

    maybe

  • edited January 28

    How are you transferring the parameter values? With ActionList: Run or ActionList: Set parameter?

    Both should be valid methods of passing a parameter value from the ActionList its in to another. Is yours an issue with parameters in general, or specifically with "Reference Scene Instance" GameObject parameters?

    I'll need more details to recreate this. Let's see some screens of the parameter's "journey" - ie. it's declaration in the ActionLists, the ways it's value is updated and used in an Action.

  • edited January 28

    The issue was specifically with "Reference Scene Instance" parameters

    I was simply using ActionList:Run to pass the data across, but a quick test shows that running a sequence of ActionList:Set Parameter and then ActionList:Run seems to work as expected

    To recreate the parameter passing issue (I've simplified it down to the basics, but it's still a bit... convoluted):

    Set up a new Scene, containg a Path with a Node Wait Time of 0.5

    Set up five Asset-Based ActionLists. TEST1 contains no parameters. All the others have a single GameObject parameter called "ActorPrefab":

    1) TEST1, contains an ActionList:Run, to run any one of TEST2a, TEST2b or TEST2c (see further below), passing "ActorPrefab" as a parameter in each case, set to "Reference Scene Instance"

    2) TEST2a is the simplest case and contains an EngineWait:2 and a Character:MoveAlongPath/Stop

    3) TEST2b, contains an EngineWait:2 and an ActionList:Run to run TEST3, passing "ActorPrefab" to it

    4) TEST2c, contains an EngineWait:2, an ActionList:Set to set the Parameter "ActorPrefab" in TEST3 to "ActorPrefab", and an ActionList:Run to run TEST3 with "Set Parameters" as FALSE

    5) TEST3, a Character:MoveAlongPath/Stop

    In OnStart:
    1) Object:Add an NPC with a Position Relative to the Path
    2) Character:Move the same NPC along the Path
    3) ActionList:Run to run TEST1

    Phew

    Anyway, run with the ActionList in TEST1 set to TEST2a. The character should start moving briefly and then stop, as expected

    Change it to TEST2b. This is my old use case (the parameter embedded in the call to the ActionList). Here the character starts moving but does NOT stop, because likely the parameter has been assumed to be a "Reference Prefab"

    Finally TEST2c, which explicitly sets the parameter before running the ActionList. The character again starts moving and then stops, as expected

    ...

    As can be seen, this is starting to drill down rather deeply, to a point where most sensible users probably wouldn't venture. To be honest, if I was you, I'd be inclined to write it off as "crazy old man WAY out of his depth" syndrome - particularly as your suggested ActionList:Set followed by ActionList:Run has the desired effect for me

  • edited January 28

    To be honest, I think I really need to rewrite all of these ActionLists to use the Hotspot GameObject parameter to identify the related NPC, as discussed in a previous thread, and ditch some of the convoluted logic that I'd originally written

    I still think there may be an issue with passing Parameters in the way I've outlined above, but, mwah, life's too short to worry about it, and there are better options for handling what I want to do in any case...

  • Thank you for the clear steps.

    Likely the parameter has been assumed to be a "Reference Prefab"

    This is exactly it. To fix it, open up SetParametersBase.cs, and add the following to line 173:

    externalParameters[i].gameObjectParameterReferences = fromParameters[i].gameObjectParameterReferences;
    
  • edited January 29

    Hi Chris, I've tried the fix, but it doesn't seem to be working for me

    I've put a debug statement directly after that line, and that shows that fromParameters[i].gameObjectParameterReferences (and consequently externalParameters[i].gameObjectParameterReferences) is set to "ReferencePrefab"

    If I manually set fromParameters[i].gameObjectParameterReferences to "ReferenceSceneInstance" in the script, then the NPC stops, as expected

  • Odd. I don't think I deviated from your instructions.

    Can you PM a test .unitypackage file with the scene, NPC prefab, and ActionList asset files?

  • edited January 30

    Hi Chris. I decided to create a test package from scratch, to ensure that none of my own modifications were muddying the waters any, and when I came to test your fix in THAT project, it...

    ...worked like a charm

    Soooo, I went back to the original project, and tried it again in THAT one, and, it...

    ...worked like a charm

    Soooo, dunno what was going on before, but maybe "switch it all off, then switch it all back on again" worked its mysterious age-old magic

    Anyway, bottom line is that your fix... works like a charm

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!