How to continue to create a map in UE4

Good day to all


In a previous article, we described how to create a level by taking the Yandex.Map section as a reference. It remains to talk about the "paving" roads and about those nuances that I encountered using World Composition, as a method of optimizing a large map.



Roads


Of course, the roads “drawn” by a level-stretched texture are quite suitable for use (for example, for an air simulator), but for a car simulator a more detailed approach is required. The most suitable component for creating roads in the UE is Spline, at least “long continuous sections”. I have not yet encountered intersections and junctions, most likely they will have to create separate objects with their hands.


Spline there are two types: Blueprint Splines and Landscape Splines . The former have tremendous customization capabilities and are well disassembled.Epic Games on the channel. With their help, you can control the creation of objects along the road at once (signposts, fences, ditches, power lines), but I didn’t find functionality to combine with the landscape at Blueprint Splines, and fitting each meter of the road with my hands under the landscape (or vice versa) is not what you want to start a project with. Therefore, I chose Landscape Splines to create roads on the first version of the level, just taking the “Edit Splines Tool” and clicking on the texture. It turned out two Splines - one for an asphalt road, the other for a dirt road. Crossroads are made simply by superimposing one on another. In order to “materialize” Spline, it is necessary for segments to set Mesh. I took the finished one from Vehicle Game, there the track, too, was made like Landscape Splines (Epic Games Launcher> Unreal Engine> Library> Vault), cutting out a complex piece about the tracks from the material.It turned out a great dirt road! It was not possible to repeat such a trick for asphalt, so I took the same Mesh, changed the texture in Material from the dirt road to the asphalt one (like this one ) and applied it on Spline with Z scale = 0.2, it turned out pretty well. In the end, you must not forget to deform the landscape under Splines, which is done with just one button, and the roads are ready:



World composition


YouTube , , , . UE : World Composition Level Streaming. «» ( , UE ). «», Level Streaming Volumes ( ), .


World Composition 4 4 16 1 1 . , — «» . , — Scale . .. Z-Scale , Z-Scale, ( 16).


World Composition , . , , , :

  1. Make current. , , ( Levels), \ . «» Persistent Level. PlayerStart «», UE , .
  2. MyGameInstance.cpp UE World Composition: Persistent Level > Persistent Level > > > . , .. , , . , , =) , . Unfortunately, my knowledge in UE did not allow me to reproduce a fix from this thread one-on-one, I just made a C ++ Class of type “GameInstance” and specified it in the project properties. MyGameInstance.h and MyGameInstance.cpp respectively:

    #pragma once
    
    #include "CoreMinimal.h"
    #include "Engine/GameInstance.h"
    #include "MyGameInstance.generated.h"
    
    UCLASS()
    class SAMPLE_01_API UMyGameInstance : public UGameInstance
    {
    	GENERATED_BODY()
    	
    public:
    	virtual void LoadComplete(const float LoadTime, const FString& MapName) override;
    };
    

    
    #include "MyGameInstance.h"
    #include "Engine/World.h"
    #include "Engine/WorldComposition.h"
    #include "Engine/LevelStreaming.h"
    
    void UMyGameInstance::LoadComplete(const float LoadTime, const FString & MapName)
    {
    	Super::LoadComplete(LoadTime, MapName);
    	
    	UWorld* World = GetWorld();
    	
    	// WorldComposition won't work in Standalone mode without next statement
    	if ( World->WorldComposition ) {
    		const TArray<ULevelStreaming*> TilesStreaming = World->WorldComposition->TilesStreaming;
    		World->ClearStreamingLevels();
    		World->SetStreamingLevels(TilesStreaming);
    	}
    	
    	// "Pause" game till streaming complete
    	GEngine->BlockTillLevelStreamingCompleted(World);
    }
    


That's all for now. The plans tell about the creation of the start menu and minimap in the game. Thank.


All Articles