Forum rules - please read before posting.

Call Event in Action List Assets and Saving

Hello,

I just wanted to clarify a few questions about Call Event, also just some 'safe practices' for saving.

  1. I noticed when converting my action lists to assets, I cannot use call event (unless objects are prefabs) is that correct?

2.There is also a few instances I am enabling and disabling components, I try not to, but occasionally game objects. Is this a 'unsafe practice'?

3.Am I able to save enabled or disabled components?

4.I believe I cannot save disabled game objects too? So if a player were to load a save, it would just default back to enabled. (I know I can do remember visible, but there a few instance where I need to disable multiple things at once)

Comments

  • edited October 2019

    I noticed when converting my action lists to assets, I cannot use call event (unless objects are prefabs) is that correct?

    Yes. This Action relies on Unity's event system, which doesn't allow for the referencing of scene objects from assets. The Object: Send message Action, however, does.

    There is also a few instances I am enabling and disabling components, I try not to, but occasionally game objects. Is this a 'unsafe practice'?

    Opinion varies on the matter, but I personally stay away from disabling GameObjects. You can control a component's enabled state through Unity's Animation system, however, so that's generally less of an issue. It's always down to the context with these kind of issues, though.

    Am I able to save enabled or disabled components?

    Can you give an example? I'm not sure if you mean a disabled "Remember" component, or a component referenced by a Remember script. If the former, then no - a Remember component must be enabled for its data to get saved. If the latter, then this should be possible.

    I believe I cannot save disabled game objects too? So if a player were to load a save, it would just default back to enabled. (I know I can do remember visible, but there a few instance where I need to disable multiple things at once)

    As above, the "Remember" component must be enabled at all times for it to work correctly. I expect it would be possible, however, for a custom Remember script to record the enabled state of a GameObject that's different from its own - so that it can separately save its state without it being disabled itself.

  • awesome thank you! So for example, I may need to disable the character controller.
    https://i.imgur.com/zay4Wzt.png Are you saying I would be able to save that? Would I be doing that through the Remember animator component? Is that the only way?

    The other example would be disabling an object. https://i.imgur.com/w9HVYBp.png Say for whatever reason I want to disable the whole object. You're saying I cant save this? What if I put a remember animator component on a parent, and disable its child, will that record it?

    Thank you for your patience.

  • edited October 2019

    Also to be extra clear, this is a action I have used to disable a few objects,

    https://i.imgur.com/CV1iO4P.png

    also this to disable individual components

    https://i.imgur.com/HPJxqXn.png

    Will I need to write custom save stuff for this? Am I doing it a dumb way?

  • @JacobJanerka You could also just rely on OnLoad and OnStart cutscenes to enable / disable the game objects depending on variable checks - this is what I'm doing in fact, it seems to be working no problem so far.

  • I may need to disable the character controller. Are you saying I would be able to save that? Would I be doing that through the Remember animator component? Is that the only way?

    While I'd recommend using the Player: Constrain Action to prevent movement over disabling the Character Controller, technically yes. To be clear: a Remember Animator doesn't save the state of your components, only the state of the animation.

    If the enabled state of the component was recorded in the character's animations, then a Remember Animator component would be able to restore it as it is able to save/load the current animation state as well as Animator parameter values.

    Again though, a custom Remember script could also do this if you only wanted this saved specifically.

    The other example would be disabling an object. Say for whatever reason I want to disable the whole object. You're saying I cant save this? What if I put a remember animator component on a parent, and disable its child, will that record it?

    While I'd recommend simply hiding an object instead, feasibly you could get by with the parenting technique you mention. Again, a Remember Animator will only save the animation state - but it's possible to record the enabled state of an Animator's child GameObject.

    What you would need to do, then, is control the on/off state through animation - rather than disabling the GameObject directly through e.g. events. Taking your object above as an example, you'd parent "Keyboard" to a new GameObject, and attach an Animator to this parent. Add two animations, "On" and "Off" that affect the Keyboard child GameObject's enabled state appropriately, and then create a bool parameter / transitions to your Animator so that setting the value of e.g. "IsOff" bool parameter plays the "Off" animation which causes the GameObject to become disabled. You'd then control this parameter value with the Object: Animate Action, rather than Object: Call event, to change the enabled state. Attaching the Remember Animator component would then store this parameter value in save game files.

    Will I need to write custom save stuff for this?

    It wouldn't be so difficult to write such a script, but the necessity really depends on the context. Making objects invisible / moving out of view is typically a faster workaround, but if you know which scene such state changes occur you can also use the OnLoad cutscene to restore objects based on e.g. a Local variable instead.

  • Thank you both for the great advice! Appreciate so much. Seems like writing my own custom save data seems like it will be more practical for the long run for specific things.

    In that specific situation, I needed to turn off the character controller so the player could clip through the floor, although you're right, there is probably better ways to do this.

    As for the remember visible component. On load I can choose appear invisible. Although there are some scenarios I'd like it to appear invisible in the editor.

    EG There is a section in which the whole room is covered in arrows, is it possible for it to appear invisible in the editor? As you can probably imagine, having huge amounts of arrows in a room is a nightmare for editing/selecting things/designing things. Of course I can just hide it in editor, and turn it on when I run the game, but I believe that leaves a bit of room for error.

  • Arrows as in Markers? You can toggle their visiblity in the Scene Manager.

  • Haha sorry, I meant as in arrows from bow n arrows.

  • You could disable their renderers and then enable them at runtime (opposite to what AC's own Marker script does.

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!