4.15 C++ Transition Guide

Currently I get reference to World from Actor->GetWorld() to avoid referencing Engine.h, but I happen to use my function only in actors :wink:
Maybe itā€™s fine in your case too?

And thanks for a tip with PCH :slight_smile:

Has anybody found a solution to access the GEngine that lies inside Engine.h ?!

It is defined inside Engine.h

[MENTION=9]Stephen Ellis[/MENTION] what do we do now to solve this :confused:

Iā€™ve fixed these errors for the plugin and am posting uploaded source on the official DoN navigation thread.

For those with similar issues, it needed:
include ā€œAllowWindowsPlatformTypes.hā€

Hi,
Iā€™ve tried to build a fresh thirdperson project with the nativize features on. But Iā€™m unable to build only if I activate it.


I got this error on build:
********** BUILD COMMAND STARTED **********
UATHelper: Packaging (Windows (64-bit)): CommandUtils.Run: Run: E:\UE_4.15\Engine\Binaries\DotNET\UnrealBuildTool.exe Test Win64 Development -Project=E:\Project\Test\Test.uproject -clean E:\Project\Test\Test.uproject -PLUGIN "E:\Project\Test\Intermediate\WindowsNoEditor\NativizedAssets\NativizedAssets.uplugin"  -remoteini="E:\Project\Test" -nobuilduht -NoHot
Reload
UATHelper: Packaging (Windows (64-bit)): UnrealBuildTool: ERROR: Couldn't find target rules file for target '-Project=E:\Project\Test\Test.uproject' in rules assembly 'UE4Rules, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
UATHelper: Packaging (Windows (64-bit)): UnrealBuildTool: Location: E:\UE_4.15\Engine\Intermediate\Build\BuildRules\UE4Rules.dll
UATHelper: Packaging (Windows (64-bit)): UnrealBuildTool: Target rules found:
UATHelper: Packaging (Windows (64-bit)): UnrealBuildTool:  UE4Editor - E:\UE_4.15\Engine\Source\UE4Editor.Target.cs
UATHelper: Packaging (Windows (64-bit)): UnrealBuildTool:  UE4Game - E:\UE_4.15\Engine\Source\UE4Game.Target.cs
UATHelper: Packaging (Windows (64-bit)): UnrealBuildTool:  UnrealHeaderTool - E:\UE_4.15\Engine\Source\Programs\UnrealHeaderTool\UnrealHeaderTool.Target.cs
UATHelper: Packaging (Windows (64-bit)): UnrealBuildTool: 
UATHelper: Packaging (Windows (64-bit)): CommandUtils.Run: Run: Took 2,9312317s to run UnrealBuildTool.exe, ExitCode=5
UATHelper: Packaging (Windows (64-bit)): Program.Main: ERROR: AutomationTool terminated with exception: AutomationTool.CommandUtils+CommandFailedException: Command failed (Result:5): E:\UE_4.15\Engine\Binaries\DotNET\UnrealBuildTool.exe Test Win64 Development -Project=E:\Project\Test\Test.uproject -clean E:\Project\Test\Test.uproject -PLUGIN "E:\Project\Test
\Intermediate\WindowsNoEditor\NativizedAssets\NativizedAssets.uplugin"  -remoteini="E:\Project\Test" -nobuilduht -NoHotReload. See logfile for details: 'UnrealBuildTool-2017.02.19-16.52.36.txt' 
UATHelper: Packaging (Windows (64-bit)):    Ć  AutomationTool.CommandUtils.RunAndLog(String App, String CommandLine, String Logfile, Int32 MaxSuccessCode, String Input, ERunOptions Options, Dictionary`2 EnvVars, SpewFilterCallbackType SpewFilterCallback)
UATHelper: Packaging (Windows (64-bit)):    Ć  AutomationTool.CommandUtils.RunAndLog(CommandEnvironment Env, String App, String CommandLine, String LogName, Int32 MaxSuccessCode, String Input, ERunOptions Options, Dictionary`2 EnvVars, SpewFilterCallbackType SpewFilterCallback)
UATHelper: Packaging (Windows (64-bit)):    Ć  AutomationTool.CommandUtils.RunUBT(CommandEnvironment Env, String UBTExecutable, String CommandLine, String LogName, Dictionary`2 EnvVars)
UATHelper: Packaging (Windows (64-bit)):    Ć  AutomationTool.CommandUtils.RunUBT(CommandEnvironment Env, String UBTExecutable, FileReference Project, String Target, String Platform, String Config, String AdditionalArgs, String LogName, Dictionary`2 EnvVars)
UATHelper: Packaging (Windows (64-bit)):    Ć  AutomationTool.UE4Build.CleanWithUBT(String TargetName, UnrealTargetPlatform Platform, String Config, FileReference UprojectPath, Boolean ForceMonolithic, Boolean ForceNonUnity, Boolean ForceDebugInfo, String InAddArgs, Boolean ForceUnity, Dictionary`2 EnvVars)
UATHelper: Packaging (Windows (64-bit)):    Ć  AutomationTool.UE4Build.Build(BuildAgenda Agenda, Nullable`1 InDeleteBuildProducts, Boolean InUpdateVersionFiles, Boolean InForceNoXGE, Boolean InUseParallelExecutor, Boolean InForceNonUnity, Boolean InForceUnity, Boolean InShowProgress, Dictionary`2 PlatformEnvVars, Nullable`1 InChangelistNumberOverride, Diction
ary`2 InTargetToManifest)
UATHelper: Packaging (Windows (64-bit)):    Ć  Project.Build(BuildCommand Command, ProjectParams Params, Int32 WorkingCL, ProjectBuildTargets TargetMask)
UATHelper: Packaging (Windows (64-bit)):    Ć  BuildCookRun.DoBuildCookRun(ProjectParams Params)
UATHelper: Packaging (Windows (64-bit)):    Ć  BuildCookRun.ExecuteBuild()
UATHelper: Packaging (Windows (64-bit)):    Ć  AutomationTool.BuildCommand.Execute()
UATHelper: Packaging (Windows (64-bit)):    Ć  AutomationTool.Automation.Execute(List`1 CommandsToExecute, CaselessDictionary`1 Commands)
UATHelper: Packaging (Windows (64-bit)):    Ć  AutomationTool.Automation.Process(String] Arguments)
UATHelper: Packaging (Windows (64-bit)):    Ć  AutomationTool.Program.MainProc(Object Param)
UATHelper: Packaging (Windows (64-bit)):    Ć  AutomationTool.InternalUtils.RunSingleInstance(Func`2 Main, Object Param)
UATHelper: Packaging (Windows (64-bit)):    Ć  AutomationTool.Program.Main()
UATHelper: Packaging (Windows (64-bit)): Program.Main: AutomationTool exiting with ExitCode=5 (5)
UATHelper: Packaging (Windows (64-bit)): BUILD FAILED

Iā€™ve looked the same kind of issue, but itā€™s about path trouble(a ! in the path) or visual studio not installed (which is not my case). And I donā€™t know why itā€™s only when i activate the nativize features.

ā€œVehicle Support moved to a pluginā€

Iā€™ve only really been using blueprints, but Iā€™d like to modify the vehicle code a bit, so Iā€™m wondering how Iā€™d access the vehicle plugin code. Do I download the engine code as normal, then is it possible to only edit/compile the vehicle plugin?

Yes, just download the engine code as normal, it would be there as plugin. No extra downloads for it.
The problem comes when youā€™ll try to move modified classes from 4.14 to 4.15, itā€™s not able to auto-compile and asks to fix classes manually through the VS.
*

Also - does anyone ported successfully modified vehicle projects from 4.14 to 4.15 yet? Help? :)*

Hi folks! Where would an experienced coder, especially with C++ start learning about the particularities of UE4 C++ ?
Iā€™ve tried the learning by doing, at Iā€™ve stumbled on a lot of UE4 coding particularities, such as the asset loading path macros, the BP-C++ interaction and other controller related problems. I tried looking up some tutorials on this, but all of them assume the reader is a beginner in C++, so they tell the reader about references, pointers, types, classes, etc. , which takes a lot of time.

Pretty sure you can solve that just by including Engine/EngineTypes.h (and if you get complains about UWorld, add in Engine/World.h).

Also, the Enum changes are deceptively nasty with 4.15. If you were using TEnumAsByte in any files, theyā€™ll need to be removed and youā€™ll need to update all those enum classes to be simple enums. The problem comes in that previously saved assets donā€™t seem to work with the new changes, so you may have to resave/reset any enum values that were previously saved to disk.

I donā€™t want GEngine because of UWorld stuff;
I need the LOG/PrintScreen functions.

Any reason you donā€™t use UE_LOG()?

Thatā€™s a tough question really, Iā€™m afraid youā€™ll have to sit through some training wheels to get to the good stuff. Look at Epicā€™s official C++ tutorial video playlist and skim through the boring stuff.

I do; but I need debug messages too.

A bit off-topic, but what does the GEngine logging have that UE_LOG doesnā€™t? I never used it actually.

I am addicted to on-screen debug messages with color-coded level of importance since I put my hands on BlitzBasic back in 2001;
I m.u.s.t use them, I canā€™t help it :stuck_out_tongue:
Itā€™s my little weird ritualā€¦

Err we got crashed from IOnlineSubsystem in 4.15.

Whenever we call the new CreateSession() with the the FUniqueNetId, the engine crash. It said the array is out of bound.
CreateSession() with the old int32 HostingPlayerNum also produce the same error and crash the engine.

We follow everything by the book closely and didnā€™t have any problem with old versions.

Anyone has any clue to this?

Best,

Dear Community,

Thank you to everyone in this thread for sharing your solutions!

So no one has found solution for GEngine yet + Debug Messages?!

I canā€™t code without my onscreen debug messagesā€¦
https://wiki.unrealengine.com/Logs,_Printing_Class_Name,_Function_Name,_Line_Number_of_your_Calling_Code!#Overview

:slight_smile:

Nothing about this yet I guess.
For now Iā€™m just going to keep on including Engine.h

Solution for GEngine in 4.15+ :heart:

If you look in EngineGlobals.h, GEngine is an extern ptr, you can make your own!

I chose to use a namespaced extern ptr :slight_smile:

YourGame.h



namespace YourCore
{
	extern UEngine* Engine;
}


YourGame.cpp



namespace YourCore
{
	UEngine* Engine = nullptr;
}



**Role of GameInstance::GetEngine()**

The Outer of GameInstance is the current engine, so it will return the correct GEngine regardless of PIE, standalone, packaged game, etc!

YourGameInstance.cpp


```


void UYourGameInstance::Init()
{
	Super::Init();
	
	//Gives proper pointer in editor PIE, standalone, and packaged game!
	YourCore::Engine = GetEngine(); //CastChecked<UEngine>(GetOuter());
}


```


Hot Reload

Because my custom Engine ptr is at project level (in YourGame.h) and not the engine level, it gets nulled on hot reload.

My solution for this was to re-set the ptr by responding to the OnHotReload() delegate. (GetWorld()->GetGameInstance()->GetEngine())



**#if WITH_HOT_RELOAD**
void AYourActorClass::OnHotReload(bool bWasTriggeredAutomatically)
{
	//Re-Set my custom engine ptr!
	UWorld* World = GetWorld();
	if(!World) 
	{
		return;
	}
	UGameInstance* GI = World->GetGameInstance();
	if(GI) 
	{
		YourCore::Engine = GI->GetEngine();
	}
}
**#endif**


See NavigationSystem.h and .cpp for the full Hot Reload implementation, I made my own OnHotReload in my chosen actor class to reset the ptr after a hot reload.

Result: Got my own GEngine now, and Hot Reload doesnt even crash! Woohooo!

Enjoy!

:heart:

Oh this is super cool!
I gonna try it next monday, thanks!

Let me know how it goes!

Have fun today!

:heart:

Hey , thanks for the tip!

That being said, since I never use on-screen debugging, I should be able to get by by just using ->GetWorld() on UObjectā€™s instead of GEngine->GetWorldFromContextObject() (Which is the only use-case I ever had of GEngine).