Forum rules - please read before posting.

Camera Prefab Workflow

Hi!
I'm trying to find a way to minimize merge conflicts when using AC. I've been experimenting with grouping together all camera-related game objects, including camera triggers, and making them into a prefab. I'm hoping that there can be a workflow where all camera cuts, for instance, are contained in such a prefab, so that edits don't need to be made to the master scene file when adjusting cameras.

As it seems that action lists are Scene-Based, I'm looking into using an asset file. I'm curious whether there's any way to create gameobject variables in an asset file, where I could assign all the cameras that I'd need to be cutting between. (right now it seems as though I'd need to create a separate asset file for each camera cut). Any help would be greatly appreciated!

Thanks and best regards.

Comments

  • Welcome to the community, @juanelo_dev.

    "ActionList assets" are an asset-based alternative to scene-based ActionLists such as Cutscenes and Interactions. They can be created by right-clicking in the Project window and choosing "Create -> Adventure Creator -> ActionList". See the Manual's "ActionList assets" chapter for more.

    AC logic components, such as Hotspots, Triggers etc can all switch to rely on ActionList assets as well. So you could, for example, have a Hotspot prefab that runs an ActionList asset when interacted with. The ActionList asset won't be part of the prefab, but can still be referenced by any instance of the Hotspot prefab.

    Having ActionList assets refer to scene objects is where things get a little more complex. AC needs to be able to keep a reference to scene objects within the asset file, and it does this by assigning a unique number - known as a Constant ID - to that object. If you drag a scene object into an asset-based Action's field, you should find that this number is automatically generated, assigned, and reported in the Console.

    Constant ID values are typically unique to one object in one scene - but if you check Retain in prefab? in its Inspector, than you can have that number be the same for all instances of that object's prefab. This way, you can have an ActionList asset locate the instance of a prefab no matter what scene you're currently in.

    A couple of tutorials on this topic can be found here:
    Referencing scene objects with ActionList assets
    Referencing scene objects with ActionList assets 2

    Going further, it's also possible to rely on "ActionList parameters" to change the values of Action fields at runtime. This way, an ActionList can be "recycled" to affect different objects in the scene. This is typically useful if you have multiple instances of the same prefab in a scene, and want to choose which instance an ActionList will refer to.

    A tutorial on parameters can be found here. Parameter values are typically set within Actions, but it's also possible to use e.g. the "Set Interaction Parameters" component to set parameter values when a Hotspot is interacted with.

  • Thank you for the quick and thorough response, @ChrisIceBox. One more question: is it possible to set custom types in the parameters for the ActionList asset? (If you could point me to the definition, perhaps I could add one myself).

    I'd like to tie it to the _Camera type that's used as an an input in the Camera Switch Action.

    Thanks again and best regards.

  • So I've gone through Enums.cs and ActionParameter.cs, as it seems that's the place to add them. I now have a ACCamera type showing up in the pulldown.

    I'm a bit stuck on what I expected to be the simpler part of this problem:
    I've created a list of parameters in the ActionList asset, each containing a reference to one of my cams, and each of said cams marked as "retain in prefab".

    I have assigned the ActionList asset to each camera trigger, and on each trigger I have set the "collider parameter" to the camera it's supposed to trigger.

    However, I can't seem to get the camera switch to occur, and if I try to print the "linkedCamera" or "runtimeLinkedCamera" from ActionCamera.cs, I get null values.
    This happens even when using the GameObject as the parameter type for the cameras. Any thoughts on what I might be doing wrong?

  • There's no need to create custom parameter types (and it's quite a bit more involved than just those two scripts, besides). Action component fields such as "New Camera" can be overridden using a GameObject parameter type.

    The Trigger's "Collider parameter" field is used to set a GameObject parameter to that of the object colliding with the Trigger - e.g. the Player.

    To set a GameObject parameter to a specific GameObject in a Trigger, instead attach the "Set Trigger Parameters" component to the Trigger and assign values there.

    If you're still having trouble, best to see some screens of your setup - since there's a lot of fields/settings involved here.

  • Thank you, @ChrisIceBox. I did come across the "Set Trigger Parameters" script a bit after posting the previous message, which has helped me get to the setup I needed. (Not sure if the Set Trigger Parameters" script is mentioned in the Action List Asset tutorials, but it might be good to include!)

    Thanks again for the terrific support.
    Best regards.

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.