C++ problem in the topic of Build a Flight Tracker with Cesium for Unreal

Hi, I am studying of the topic above. But problems occur at the very beginning, when I create the New C++ actor class, the message: Project now includes sources, please close the editor and build from your IDE. pop up. Then, I press OK. The second message pop up: Successfully added class ‘PlaneTrack’, however you must recompile the ‘MyProject3_copy’ module before it will appear in the Content Browser.

Would you like to edit the code now?

After that, even I did not change anything but error occurs when running the debug: The following modules are missing or built with a different engine version. Would you like to rebuild them now? . What can I do?

What modules does it say are missing?

Did you try saying “yes” when it asks if you want to rebuild?

Yes. I tried and compiled the project, but it failed to build.
---------- Creating patch ----------
Running D:\UE_5.0\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.exe -Target=“MyProject3_copyEditor Win64 Development -Project=”“C:/Users/xxx/Documents/Unreal Projects/MyProject3 - Copy/MyProject3_copy.uproject”“” -LiveCoding -LiveCodingModules=“D:/UE_5.0/Engine/Intermediate/LiveCodingModules.txt” -LiveCodingManifest=“D:/UE_5.0/Engine/Intermediate/LiveCoding.json” -WaitMutex -LiveCodingLimit=100
Quick restart disabled when re-instancing is enabled.
Log file: C:\Users\xxx\AppData\Local\UnrealBuildTool\Log.txt
Invalidating makefile for MyProject3_copyEditor (MyProject3_copy.Build.cs modified)
WARNING: Errors generated while parsing ‘C:\Users\xxx\Documents\Unreal Projects\MyProject3 - Copy\Source\MyProject3_copy\MyProject3_copy.Build.cs’
C:\Users\xxx\Documents\Unreal Projects\MyProject3 - Copy\Source\MyProject3_copy\MyProject3_copy.Build.cs(26,1): error CS8652: The feature ‘top-level statements’ is currently in Preview and unsupported. To use Preview features, use the ‘preview’ language version.
C:\Users\xxx\Documents\Unreal Projects\MyProject3 - Copy\Source\MyProject3_copy\MyProject3_copy.Build.cs(26,1): error CS8803: Top-level statements must precede namespace and type declarations.
ERROR: Expecting to find a type to be declared in a target rules named ‘MyProject3_copyEditorTarget’. This type must derive from the ‘TargetRules’ type defined by Unreal Build Tool.
Build failed.

Those are some strange errors. It sounds like something is either very wrong with the .Target.cs and .Build.cs files, or something is wrong with your .NET environment.

I just tried it myself in UE 5.0, and it worked ok. The only thing I’d suggest is that after it says “Project now includes sources, please close the editor and build from your IDE” and it opens in Visual Studio, you close Unreal Engine and then do Debug → Start Debugging in Visual Studio. This will compile the project and launch the Editor again.

With the Editor running, it tries to do a Live Coding recompile (that’s what I see in your log), which can be more error prone.

You can also potentially save yourself some trouble by creating a new project and choosing “C++” instead of “Blueprints” at creation time. Then you won’t need to convert it to C++ later, which is where you seem to be running into trouble.

I tried to create C++ directly, the above problems solve. However, the C++ compile is still fail.
error CS8652: The feature ‘top-level statements’ is currently in Preview and unsupported. To use Preview features, use the ‘preview’ language version.
** error CS8803: Top-level statements must precede namespace and type declarations.**
** ERROR: Expecting to find a type to be declared in a target rules named ‘testtttttEditorTarget’. This type must derive from the ‘TargetRules’ type defined by Unreal Build Tool.**

What does your .Target.cs look like? If a default Unreal C++ project doesn’t compile, you may have to take it to a more general Unreal forum for help figuring out what is wrong with your setup.

I finally can compile all C++ coding in UE. But I have another two problems.

  1. the spline is very short, shorter than a cube.
    2, I set all the blueprint, but once I pressed the M key in game mode, the aircraft just disappear and the camera did not move like following a path.

The fight tracker can be implemented in Blueprint only. The C++ code can be replayed by using CesiumCartographicPolygon in Blueprint.
1.The CSV file is imported as DataTable
2.Add a CesiumCartographicPolygon in outliner, closed loop unchecked
In Level Blueprint, get CesiumCartographicPolygon object reference. At the beginning, clear the points of CesiumCartographicPolygon.Then make a loop based on the number of rows in the DataTable. Read in the values of each row in DataTable, and then convert the latitude and longitude height into UE coordinate values.Then add the points in CesiumCartographicPolygon according to the latitude,longitude and height.
3.In the Event Graph of BP_Aircaft, use the CesiumCartographicPolygon object reference to Get Polygon to Get Transform at Distance Along Spline to Set Actor Transform.

Can you please tell us how you solved the previous problem, in case others run into it?

If @pjiang9’s suggestions didn’t help, please start new threads for these questions and provide more details about what’s going wrong.

I guess it is my problem of putting the code in wrong place, and some of it repeated with the original source code. Thanks for all your help!