Seeking advice on the correct usage of [Maintaining State at the End of a Scene]

Hello everyone.

I created a destructible wall for the scene. When the trigger condition is met, the wall breaks and becomes a passageway.

↑ The setup is quite simple. Initially, collision is enabled for this object. When the condition is met and the trigger activates, the animation disables the collision box. This is a single-direction action.

The problem is that no matter how I configure it, as soon as I return via the portal, the wall inevitably reverts to its initial state.

I tried using the “Save State” option. Before leaving the scene, when reading the save file, the wall object remains in the [end] state. However, once I leave the scene, it always returns to the [wall] state.

image

↑ So I decided to check the Persist State at End of Scene option in the base settings node.

But after checking it, I encountered even more issues:

Issue 1: After checking it, saving and then loading the game reverts the wall to its initial [wall] state.

Issue 2: Even with the option checked, if I leave the scene via the portal and return, the wall object still reverts to the [wall] state.

This is very confusing to me. Could anyone explain how to make an object maintain its final animation state permanently?

How exactly do I trigger the functionality of this Persist State at End of Scene option?

Maintain State on Scene End just preserves which state the object starts in when you return to the scene. It doesn’t preserve the properties or values changed along the way (it might maintain switch/variables I cannot remember). So if your end state is blank, the object loads into that blank state but the changes from breakthrough won’t carry over.

Just to verify, the property changes (collision disabling, broken animation, etc.) need to be set up in the end state itself, not only in breakthrough. That way when you come back, end gets loaded fresh and applies those properties.

One caveat with animation: if you’re using one in end, make sure end has its own animation set rather than relying on continuation from breakthrough, since the object jumps directly from initial to end on scene load.

Thanks so much for the reply! I think I didn’t quite get it :rofl:

Just to confirm: if the option “Maintain State at End of Scene” resets to the initial state when switching scenes, then we can’t rely on it to achieve permanent scene effects.

My [end] action is a single-frame animation of a broken wall.

If I need this object to permanently stay in the [end] state after the trigger condition is met, what’s the easiest way to do that?

Update:

I’ve already used a global switch to determine the object’s animation state. Although there’s a one-frame glitch when entering, it’s the only method I can think of for now.

After further testing on my end, I wanted to come back and clarify some of what I said in my first post.

From what I’ve found, when you leave the scene it makes an exact duplicate of the object, and when you come back it generates a new object where it was previously with the properties and everything kept. So if you change a property in a previous action and come back to the scene, that property stays how it was when you left. So I was a bit off earlier saying properties don’t get kept, looks like they actually do.

Original start of playtest:
agm.windows.editor.x8664W1qJXkLP0g

When reentered scene:
agm.windows.editor.x8664K2UaLW2rqW

One thing I noticed: to get a debug print in the maintained state, I had to have at least a 0.03 second wait in front of it. Some actions seem to happen instantly though, so I’m not totally sure if those run before the state is fully restored or if the property is already there by then.

Do you have an animation set as the default on the AnimationPlayer? I wonder if that’s hanging up at the very beginning. There is a current bug report in for initial load times starting with the default animation and then a short blip before it goes to what it’s supposed to be at. The devs are working on scene transitions as far as that bug, so I think we might be waiting on that fix for this exact behavior.

For now, try making sure the AnimationPlayer has no default animation set. None of the animations in the list should have the autoplay icon checked. Here is what the icon looks like so you know what to look for:

1 Like

Indeed!!! As you said, if the default animation is loaded, this 1-frame flicker occurs. If the initial default animation is removed, this problem does not occur.

I initially thought that [Maintain State at Scene End] was ineffective.

I previously used a global switch to control it, but there was still a 1-frame flicker when returning from the portal. This was caused by the default animation. After disabling the default animation and enabling [Maintain State at Scene End], the final effect was successfully maintained upon returning from the portal. However, if the default animation is enabled, it reverts to the initial state.

This seems to be a rather serious bug, and I hope the development team can resolve it.

(Also, I hope the development team can quickly fix the issue regarding the respawn position of child objects after they disappear.)