quinta-feira, 30 de julho de 2020

Viewing the C++ Project in Visual Studio

After creating a C++ project in Unreal Engine, Visual Studio will open automatically. Visual Studio uses the concepts of Solutions and Projects. Related projects are stored within a Solution.

Unreal Engine created a Solution file called TutoProject.sln. This Solution contains two projects, one with the name UE4, which contains the files of the Unreal Engine, and the other with the name TutoProject, which contains the files of our game.

The image below shows the Visual Studio Solution Explorer window. It is open by default, but if it is not visible you can open it in the View > Solution Explorer menu.


A tip for those who are starting to program in C++ on Unreal Engine: In the beginning, don't worry about understanding the meaning of all the existing files in the project. Focus on the files that you can edit and the location where the files you create will be placed.

The C++ classes of the project we created can be seen in the image above, in the path Games/TutoProject/Source/TutoProject. A C++ class is represented by two types of files. One of the file types has the extension .h and is known as Header. This file contains the definition of the C++ class. The other file type has the extension .cpp and contains the implementation of the functions of a C ++ class.

In the image above, we can see that there are already three C++ classes in our project:
  • TutoProject: This class is used by Unreal Engine, you will not modify it.
  • TutoProjectCharacter: This class represents the player.
  • TutoProjectGameMode: In this class, we will put the rules of the game.

Changes made to C++ classes need to be compiled in order to be applied in the game. Compilation is the process of converting C++ text code into a program.

To compile the project in Visual Studio, right-click on the TutoProject project file and choose the Build option. You can also compile from the Unreal Engine editor by clicking on the Compile button.