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"

Why are both of these functions that are supposed to give me level bounds returning a single point at 0,0,0?

I'm trying to get movable objects to become part of the level they're in when it unloads so they don't just fall into the void (I'm using world composition if it matters). As far as I can find it can only be done with C++ so I started using it and created a LevelScriptActor class and I'm trying to do this:

 void AMyLevelScriptActor::EndPlay(const EEndPlayReason::Type EndPlayReason) {
     this->MoveActors();
     Super::EndPlay(EndPlayReason);
 }
 
 void AMyLevelScriptActor::MoveActors()
 {
     ULevelStreaming *ThisLevelStreaming = FLevelUtils::FindStreamingLevel(this->GetLevel());
     ULevel *LoadedLevel = ThisLevelStreaming->GetLoadedLevel();
     //FBox LevelBounds = ALevelBounds::CalculateLevelBounds(LoadedLevel);
     FBox LevelBounds = ThisLevelStreaming->GetStreamingVolumeBounds();
     FString debug = ThisLevelStreaming->GetWorldAssetPackageName() + " - " + LevelBounds.Min.ToString() + " - MAX " + LevelBounds.Max.ToString();
 
     if (GEngine)
         GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, debug);

This prints the name of the level that's unloading correctly but both Min and Max are 0,0,0 so my objects will never be inside it, whether I use the commented out LevelBounds or the other one.

I learned most of this from these links: https://wiki.unrealengine.com/Streamed_Levels,_Test_If_Actor_Is_In_Level_Bounds https://wiki.unrealengine.com/Solus_C%2B%2B_Tutorials#Solus_C.2B.2B_Tutorial:_Creating_Custom_Level_Blueprints_in_C.2B.2B

Product Version: UE 4.20
Tags:
more ▼

asked Aug 30 '18 at 12:15 AM in C++ Programming

avatar image

HallwayWalker
20 3 2 6

avatar image HallwayWalker Aug 30 '18 at 01:45 AM

I've discovered it prints something other than 0s if the level unloaded because I'm loading my game/opening the persistent level again, but I don't know why or if that can help me in some way.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

It works if I get the bounds on beginplay, using

 LevelBounds = ALevelBounds::CalculateLevelBounds(LoadedLevel);

Even though everything I've found indicates EndPlay fires before anything is actually unloaded so I don't see why getting the bounds then should be any different...

more ▼

answered Aug 30 '18 at 03:59 PM

avatar image

HallwayWalker
20 3 2 6

(comments are locked)
10|2000 characters needed characters left
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