How I keep learning UE4 while making my game

Good day to all


In this article I want to talk about the problems that I encountered while continuing to develop a car simulator and what I came up with when trying to get around them.

World composition


In a previous article, I talked about how it is simple and fast to create a large world in UE4, divided into pieces to optimize loading. As a result, I abandoned this mode for the following reasons:

  • First of all, I drew attention to the fact that in all the examples and videos, the Epics themselves (and other developers) make 8km x 8km cards “whole”. This is even more than I need, so World Composition for me is, apparently, a kind of over optimization.
  • paving roads with Landscape Splines, I noticed that UE4 does not break them down by the size of the map cell (at the joints), but extends its borders by the size of the resulting Spline. This causes problems when trying to move the map, and it also seems to spoil the dynamic loading logic, loading immediately everything that the road passes through (in my case, this is half the world).
  • the border of the pieces of the map is generally an interesting question. I redid the roads for the home-made Blueprint Spline (more on that below) and, in order not to repeat the “mistakes” of Landscape Splines, I had to implement automatic spline splitting into pieces at the level boundaries, synchronizing bends in these places, creating child objects (so that each one has its own place the level for auto loading) ... I’m not sure that this is possible in principle, and it would certainly take a lot of time (I didn’t find references to level boundary functions, etc. in Blueprints)
  • falling through the map. About the bypass of this "feature" using BlockTillLevelStreamingCompleted () I already talked about in that article. However, this solution led to the following problem:
  • . ( ) OpenLevel ( World Composition), «» -, .. spawn , , . , ++, «StreamingPauseRendering» override «BeginLoadingScreen». , , .
  • , World Composition ++

    void UMyGameInstance::OnWorldChanged(UWorld * OldWorld, UWorld * NewWorld)
    {
    	Super::OnWorldChanged(OldWorld, NewWorld);
    
    	if (NewWorld) {
    		if (NewWorld->WorldComposition) {
    			const TArray<ULevelStreaming*> TilesStreaming = NewWorld->WorldComposition->TilesStreaming;
    			NewWorld->ClearStreamingLevels();
    			NewWorld->SetStreamingLevels(TilesStreaming);
    		}
    	}
    }
    

Blueprints Spline


, Blueprints Spline «» ( , , «» ), Landscape Splines «Deform Landscape to Splines». , «», "Editor Apply Spline" Landscape + Spline! «Call In Editor» Blueprint Spline ( ) . .


Widgets


, Vehicle Variety Pack , , , , , . 3D , Widget, , ! Workaround' «Render Target», 3 , «» , , , Widget. , « » .



, UE4, ( , ). Udemy , , , , , \ . , , , «» ( PlayerController) . AI Controller Class «dummy» AIController, .



Suddenly it turned out to be a problem to close the menu in the game by pressing Esc. There was no difficulty in catching the Esc in the game, pausing the game and opening the Menu Widget in full screen ... but he didn’t hurry to close Esc again, the override “On Key Down” started to work in some unobvious situations, such as “calling the console UE4 by ~, then close it, then press something ... ”The solution turned out to be painfully simple - check the“ Is Focusable ”checkbox in the Widget designer on the root element (on Widget itself).


Thank you for your attention, if I manage to break out of the released Mount & Blade II: Bannerlord and not fall into the outgoing Snowrunner, then I will continue to develop my project and write about all the unobvious things that took a lot of nerves and time.


All Articles