Forum rules - please read before posting.

Spawnable or "dynamic" Constant ID + ActionList "live link"

edited April 16 in Technical Q&A

Hello again everyone on the forum, the situation is as follows:

I'm developing my AC-based NPC spawning system. The NPCs themselves are controlled by EmeraldAI, packaged into prefabs and spawn without problems when using the Action Object: Add or remove > relative to Game Object (marker with constant ID). However, NPC prefabs (+ markers) appear dynamically in the scene, and the Action Object: Add or remove always references the same marker with the same constant ID. In result, despite the actual distribution of the markers throughout the scene (all with the same constant ID), the Action naturally adds NPCs to only one single marker, ignoring others.

Do you have any ideas about this? I was thinking about generating a random ID when spawning each prefab into the scene, but how is it possible to make the ActionList attached to the prefab "see" exactly its exclusive ID and update all references within ActionList itself?

Comments

  • Sorry, I'm not clear - are you referring to the NPCs that spawn, or the Markers that they used as position reference when doing so?

    When spawning an object with Object: Add or remove, you can assign the spawned object to a GameObject parameter if one is defined in the ActionList. If you have later need for it further down in the ActionList (or need to pass to another), you can then rely on that parameter as a dynamic field rather than assigning a prefab directly.

    If that's not possible, you can still rely on GameObject parameters for any ActionList field that uses dynamic content, and update its value through scripting.

  • Thank you Chris, I meant that markers spawn on the terrain, and each such spawn triggers the same ActionList, which adds a random NPC prefab to the scene (to the marker transform point). The ActionList called always the same, the marker linked in the "Object: Add or remove" is also the same with specific constant ID.

    But I thought that it might be possible to update such marker reference each time in the "Object: Add or remove". I figured out how to assign each spawned marker its own new constant ID - now works, but the problem of updating the field in the "Object: Add or remove" remains.

    I'll try to explore the topic of parameters as you suggested. I hope something works out.

    In fact I want to create a system that allows dynamically linking any fields in any AC Actions with any objects appearing in the game world through third-party procedural spawners (like SoulLink or Crux). Because when it's 5-10 objects at the scene, it's not a problem - 10 separate ActionLists with unique references to 10 objects. But what if there should be hundreds of these objects and they spawn procedurally? That's the problem for me.

  • edited April 18

    Thanks for the details. Parameters are likely the answer here, rather than Constant ID numbers. Parameters will create a direct link to the objects at runtime, and are intended to aid with dynamic content.

    How you set parameter values may vary based on need. As above, the Object: Add or remove Action can assign the spawned GameObject as a parameter than can then be used either elsewhere in the same list, or passed to another.

    It's also possible to set parameter values, and run ActionLists, through script - which may be the better choice if you're also dealing with third-party assets. For example, to set an ActionList asset's first parameter to a specific GameObject, and then run it:

    AC.ActionListAsset actionList; // Set elsewhere
    GameObject gameObjectValue; // Set elsewhere
    
    actionList.GetParameter ("My parameter").SetValue (gameObjectValue);
    actionList.Interact ();
    
  • Thank you so much, Chris! I'll dig in this direction.

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.