Forum rules - please read before posting.

[Feature Request] Parameters in Actionlist editor: Expose GameObjects' IDs as Integers for compariso

edited November 2019 in Engine development

Hi there!

Here's the scenario:

I need to save the ConstantID of an Object in a global variable, and check via an action in an ActionListAsset, when loading a savegame, if the object ID passed as parameter (as GameObject) is equal to the global variable int I set in the action.
That is, when loading a game, I need to determine if an GameObject running an ActionListAsset is the same as the one stored in the global variable. And, if so, do some more actions.

Such gameobjects are actually SavePoints(instances of a SavePoint) prefab, there could be more than 1 per scene, each one with a different ID, but just 1 is the one I should activate on loading: the one which has the ID equal to the lastSavePointID global integer variable.

In more detail: when saving the game, I'm also saving as a global variable the last SavePoint ID (a gameobject with a little collection of scripts) used to save the game.

So, when loading, since each Savepoint has an ActionListStarter triggering on load, calling an ActionListAsset with 2 parameters, and the SavePoint is also a prefab, the Savepoint checks the first parameter (which can be referenced inside the same prefab), that is the SavePoint Gameobject itself, against the global variable int value.
(and the second one is a per-Scene camera ID to be used/restoring when loading a game from that savepoint).

Would it be possible to add to the list of the int parameters the IDs of GameObject passed as GameObjects, at least to make some comparisons with variables, and to set the variables values?

I know it's a bit of a corner case scenario (or, at least, I believe so), since it would be the only way I can think of of saving the reference to a scene Object ID in a global variable, but if I can't do that, I should just use pure code, or a few custom actions.

Maybe have another action to mix/match Set/Check Object IDs and integer Variables?

more details and context about what I'm doing:
When saving the game, the camera blends to a camera contained inside the SavePoint (it points to an open book on a pedestal, and a dialogue appears asking to save), using a battle-tested little bunch of scripts/actions to handle progressive, stacked closeups on objects.
So, when saving, it saves the actual active camera instead of the last gameplay camera.
So, as expected, when loading the game, it starts with the last active camera (looking at the book), and not the other one.
Also, I'm saving the game while restricting the player movements, so when it loads up, it's forever stuck looking at the book.

I was trying to restore a playing state, by storing in the SavePoint (instance) the Camera ID (as a gameobject reference from the scene) and switching to the proper CameraID (which is not necessarily the closest to the SavePoint) depending on the SavePoint ID.
But since I can't compare the numerical ConstantID of two GameObjects against an int variable, I can't do the check (using Actions).
Manually typing the ID of the camera gameobject as an integer doesn't feel very safe or maintainable.

I could also store as a global variable the ID of the desired onload camera when saving but I also need to do some extra code execution on the SavePoint bound to that camera.

I can think of either:

  • Create a custom action, specific for checking a named global variable against a gameobject
  • Do everything by code

Comments

  • So essentially, you're asking to be able to check by Constant ID integer value when using the ActionList: Check parameter Action - in an ActionList asset - to query a GameObject parameter value?

    Should be possible.

  • Yup, basically, yes.

    Check or Set, to avoid doing the cast via Custom scripts.

    I basically had the ActionList Asset ready, but realized it wasn't possible a bit too late :P
    (I rewrote the cutscene via code - nothing too complex, but unexpected. This also led me to some brainstorming on other threads I opened)

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.