x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Is there a way to reset an actor to the state it was in when it spawned ?

Hello !

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 ?

Thanks a lot for your help !

Product Version: UE 4.21
Tags:
more ▼

asked Apr 20 '19 at 10:24 PM in Blueprint Scripting

avatar image

N0rgannon
22 1 1 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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.

more ▼

answered Apr 21 '19 at 09:20 AM

avatar image

Everynone
13.8k 74 25 58

avatar image N0rgannon Apr 21 '19 at 02:26 PM

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 ! :D

avatar image Everynone Apr 21 '19 at 06:12 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Apr 21 '19 at 08:26 AM

avatar image

linden1029
25 4 5 7

avatar image N0rgannon Apr 21 '19 at 02:26 PM

I think that's just what I'll do for a start and improve upon that when I get the time ! Thanks for sharing your insight ! :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question