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"

Knowing When a Level is about to be unstreamed, but still accessing its members before it fully unstreamed

Dear Friends at Epic,

I extended LevelScriptActor,

and I have been happily using and setting custom values for my levels which are re-parented to use this new ScriptActor

I am doing this to facilitate the tracking of level streaming.

I have an issue though.

My extended level blueprint has variables with important data that I want to save

  • when the level is about to be unstreamed

  • before it is deleted, so that its member values are still filled with data

I've tried using different events in C++, and it is not working


In the code below, the name always shows up as none, and other member var data is also now invalid how can I get the member var data after unstreaming begins, before the level is deleted and member var data lost?

 //LevelScriptActor.h         BeginDestroy()
 void AVictoryLevelScriptActor::BeginDestroy()
 {
     Super::BeginDestroy();
     //~~~~~~~~~~
     
     UE_LOG(Victory,Error,TEXT("STREAMING LEVEL UNLOADED (name is expected to be none) %s"), *GetName());
 }

The member variables are already null/filled with default data by the time I know the level is about to be unstreamed

In the level blueprint graph, the event destroy node never seems to be called.


My Question

What is the way I can know within the level script actor itself, that it is about to be unstreamed, before it is unstreamed, and its member vars are still filled with correct data?

Request

if this is not yet possible please make it possible, to facilitate management of levels streaming in and out and enabling me to follow the object oriented model of keeping level-specific data within the level bluepirnt class

Thanks!

RAma

Product Version: Not Selected
Tags:
more ▼

asked Mar 11 '14 at 02:02 AM in Everything Else

avatar image

ue4-archive ♦♦ STAFF
50.1k 3672 2002 9129

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

1 answer: sort voted first

BeginDestroy is after garbage collection has been run and the object is about to be deleted giving it an opportunity to release any resources that may require time to complete.

Have you looked at ReceiveDestroyed? I can't recall off the top of my head if it fires in the case of level streaming, but it probably should.

more ▼

answered Mar 11 '14 at 02:02 AM

avatar image

ue4-archive ♦♦ STAFF
50.1k 3672 2002 9129

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:02 AM

Please Add ReceivedDestroyed to LevelScriptActor

I just tested it, and the log does not show up

It's not that it shows up as "none",

it does not show up at all

.h

 virtual void ReceiveDestroyed() OVERRIDE;

.cpp

 void AMyLevelScriptActor::ReceiveDestroyed()
 {
     UE_LOG(MyLevelBPLog,Error,TEXT("STREAMING LEVEL RECEIVE DESTROYED (name should not be none) %s"), *GetName());
     
     Super::ReceiveDestroyed();
     //~~~~~~~~~~
 }



BeginDestroy log does show up

//LevelScriptActor.h BeginDestroy() void AMyLevelScriptActor::BeginDestroy() { Super::BeginDestroy(); //~~~~~~~~~~

     UE_LOG(MyLevelBPLog,Error,TEXT("STREAMING LEVEL UNLOADED (name is expected to be none) %s"), *GetName());
 }

Thanks Marc!

Rama

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:02 AM

Alright, now that I actually took more than 30 seconds to look at the code I see the function you should be using: OnRemoveFromWorld

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:02 AM

alt text

Yaay!

That did it!

Thanks for the More than 30 secs Marc!

Rama

PS:

the code for others

 void AMyLevelScriptActor::OnRemoveFromWorld()
 {
     UE_LOG(MyLevelBPLog,Error,TEXT("STREAMING LEVEL UNSTREAMED (name should not be none) %s"), *GetName());
     
     Super::OnRemoveFromWorld();
     //~~~~~~~~~~
 }

tymarc.jpg (39.1 kB)
(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