What I would like to achieve is to reset the enemies in my level when the player character reaches a save point trigger.
I wondered if there is an already built-in way to tell a enemy ( Actor) to reset to its original state (internal variables, position, rotation…). Alternatively (or even better actually), is there a way to spawn a duplicate of the enemies in my level (as they were when the level was spawned) while keeping the ones that were previously spawned still alive and well ?
The Reset Level doesn’t seem to be what I am looking for (even though I don’t really understand its purpose) and the Open Level is too brutal (it loses everything statewise). The individual Actors don’t seem to have a Reset method built-in but I guess in the worst case scenario I could build one by storing the initial information when they spawn to be able to reset them later manually.
Do you have any insight into if it is actually possible to achieve my goal using built-in methods at some level ?
Get Class → Get Class defaults will get you the original variable values. Write a small reset function in the base class and restore them. Should work for something straightforward.
Or give the actor a default struct and a modifiable struct. When you want to reset the actor, set the modifiable struct to the the default one (or fetch one from a data table). You will still need custom functionality to restore things that are your game specific, ofc.
Another good method applicable to more complex setups is to envelop variable sets / structs with components. You can then have the components reset themselves (call their own reset functions that you wrote) without worrying about inheritance. More upfront work and way more planning here but you reap the benefits further down the line.
It depends heavily on what your game is atm and where you’re taking it next.
I don’t know of anything one node that would help. The way I would do it is just have a struct for all the variables you want saved and store that in the game state. Then you can reset the level and call on that info. Not sure if that helps.
That is kind of what I had in mind but better explained. I’ll try to look into the component envelope when I get the time. For the start, a simpler original state struct, as suggested, would be working fine I guess. Thanks for your insights !
Yeah, structs work well - especially that you might want to save that data anyway, as you mentioned!
The components are useful when you build something big and modular. You can then keep some of the reusable functionality there. You’d actually combine that with structs.