Forum rules - please read before posting.

Creating pickup logic through action lists

Hey folks,

I'm trying to create my own pickup logic through ActionLists. I'd like to be able to parent a given object to the player and translate it to the HeldItemMarker located in the player prefab.

My first hurdle is there the relevant Actions don't allow the player as a target for translating to, or setting a parent of.

I'm attempting to get around this by creating Global Variables for both the Player and the HeldItemMarker.

I seem to be successfully setting those Global Variables (they come up as assigned when I'm checking during runtime.) However, the Object: Transform and Object: Set Parent don't like using Global Variables. To get around this I'm trying to use Variable: Copy to assign the values from the Global Variables to component variables.

I admit, this doesn't feel...correct. It's just the best idea I've had so far. And it's likely not correct, because it's not working.

Here's a shot of the actionList asset that's attempting to set the player as the parent of a cube in the scene.

https://imgur.com/a/h6Y7n7n

I've successfully gotten the test cube to translate to a marker that lives in the scene. And set the cube as a child of the same marker It seems my stumbling block is correctly passing the global variables through.

Any help appreciated!

Comments

  • This is when working with an ActionList asset file?

    It should just be a case of assigning the prefab object directly in the Action, and having AC automate the connection via a Constant ID number. It shouldn't be necessary to rely on variables - and parameters are only necessary for fields you wish to be dynamic.

    AC's Constant ID system is its way of handling the connections between asset files and scenes. At runtime, you won't want the prefab itself to be affected/referenced - but the scene instance of it. AC will look for the scene object with a matching Constant ID value when the Action runs.

    In your Player prefab, locate the HeldItemMarker object and attach a Constant ID component. Check Retain in prefab? to assign it an ID value that should be constant throughout the project. i.e. at runtime, the HeldItemMaker inside the spawned instance of the Player should have the same ID value. Any Actions that then reference this ID will affect the scene instance - not the original prefab.

    If you assign the HeldItemMarker into an Action (e.g. the Object: Set parent Action's Parent to field, no parameter overrides), the Constant ID value should then be recorded and displayed in the Action. Is this not the case?

  • Hey, yeah I'm trying to make the pickup a pretty generic item that I can dupe as prefab, and similarly I'm trying to keep the logic pretty generic. So I'm using an ActionList asset.

    When I try adding the character's HeldItemMarker directly it will work if the character lives in the scene. But I think the correct way to operate would be to load the character with a player start, correct? Otherwise every scene has to have the player living in it.

    When I try adding the marker to the ActionList it gets upset.

    My goal is to create objects that I can just drop into scenes that are agnostic about scene variables/situations/what have yous. The longer term goal would be to create a generic "pick up" prefab and use nested prefabs and overrides to add specific art and settings per pickup. So, the paperweight and the stapler are both the same base prefab and the art is a child of that prefab. But maybe this is going against the grain of AC's intended workflow?

  • Adding HeldItemMarker directly shouldn't prevent the Player from being able to be spawned in - that's the intent behind the Constant ID system.

    When I try adding the marker to the ActionList it gets upset.

    Can you share full-screen screenshots of this workflow? I'll need to be more clear on where/how AC is complaining.

    What are your AC/Unity versions, also?

  • Ahhhhh, I get it now. It works! So the workflow is you assign the specific game object once, and that records the constant ID in the asset list. Ok, awesome. Even though the field goes blank I see where it shows the constant ID beneath.

    Just as a postmortem: I misunderstood why it wasn't working. I had been assigning both the object to be moved and the target marker through parameters (which was not working for the target marker because I was trying to use Global Variables). I turned off the Set Interaction Parameters component because I switched to leaning on the Constant ID as the assigning mechanism...this worked for the target, but I forgot to do the same with the object to be moved. The Set Interaction Parameters component was no longer feeding in the Object to be Moved. Once I used the same method for both it worked!

    Thanks a bunch! I'll keep banging away at this and see where I get stuck next :smile:

  • Just to be perfectly clear, when I said AC got upset, I misinterpreted this "missing" text as it being broken. I missed the constant ID text beneath.

    https://imgur.com/a/8lrRNzp

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.