Reader small image

You're reading from  Unreal Engine 5 Game Development with C++ Scripting

Product typeBook
Published inAug 2023
Reading LevelBeginner
PublisherPackt
ISBN-139781804613931
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
ZHENYU GEORGE LI
ZHENYU GEORGE LI
author image
ZHENYU GEORGE LI

Zhenyu George Li is a passionate video game developer with 20+ years of experience. He has contributed significantly to many games and serves as a senior development consultant at Unity. His early immersion in technologies like C/C++, DirectX, OpenGL, and Windows GUI laid the foundation for his success. Notable titles in his portfolio include Magic Arena, Halo Infinity, Stela, Dead Rising 2, and The Bigs 2. He has gained extensive knowledge in programming, graphics, animation, gameplay, AI, multiplayer, and UI using Unreal and Unity engines. Additionally, he has taught UE at Vancouver Film School and has college teaching experience at College of Interactive Arts and Hefei Union University.
Read more about ZHENYU GEORGE LI

Right arrow

Converting an existing Blueprint project to a C++ project

UE provides a very straightforward way to convert an existing Blueprint project to a C++ project. All you need to do is add a C++ class to your project and then let UE take care of the conversion and add the needed project files:

  1. First of all, you have to create a Blueprint project, MyBPShoopter, under C:\UEProjects (you can choose a different path to create the new project). Use the same steps introduced in the Creating the MyShooter C++ project section, but choose BLUEPRINT instead of C++ for the creation of the MyBPShooter project.
Figure 1.12 – Creating MyBPShooter in UE5

Figure 1.12 – Creating MyBPShooter in UE5

  1. Secondly, open the new project in UE5. Pay attention to the project tree; it doesn’t have the C++ Classes node at this stage.
Figure 1.13 – Open MyBPShooter in UE5

Figure 1.13 – Open MyBPShooter in UE5

  1. Select Tools | New C++ Class from the editor’s main menu, and then, in the Add C++ Class window (see Figure 1.14), choose Character as the base class (a class that contains common attributes and methods that are shared by its derived classes) to create the MyShooterCharacter class.
Figure 1.14 – Adding a new C++ class from the Character class

Figure 1.14 – Adding a new C++ class from the Character class

Once you click the Next> button, it will navigate to the NAME YOUR NEW CHARACTER screen.

  1. On the NAME YOUR NEW CHARACTER screen, type MyBPShooterCharacter into the Name field.
Figure 1.15 – Adding the MyBPShooterCharacter C++ class

Figure 1.15 – Adding the MyBPShooterCharacter C++ class

Please pay attention to the path where the header and the source files will be placed. They look different from the MyShooter project because the C++ node hasn’t been created yet. Don’t worry about it at the moment. Once the conversion job is done, the system will automatically move the files to the right place.

  1. After clicking the Create Class button, you will see a progress bar.
Figure 1.16 – The MyBPShooterCharacter C++ class Adding code to project… progress bar

Figure 1.16 – The MyBPShooterCharacter C++ class Adding code to project… progress bar

Wait for the pop-up message, which indicates that the C++ class job has been added.

Figure 1.17 – A message saying that the MyBPShooterCharacter C++ class is now added

Figure 1.17 – A message saying that the MyBPShooterCharacter C++ class is now added

  1. Click the OK button. Now, you will see the message dialog, which asks you whether you want to edit the code (see Figure 1.18). Choose No here.
Figure 1.18 – Dialog for editing the MyBPShooterCharacter source code

Figure 1.18 – Dialog for editing the MyBPShooterCharacter source code

  1. Shut down your UE editor and reopen MyBPShooter. When you see a dialog that asks whether you want to rebuild the project, answer Yes here.
Figure 1.19 – The rebuilding MyBPShooter dialog

Figure 1.19 – The rebuilding MyBPShooter dialog

When it is done, you will find the new C++ Classes node on the project tree, and the MyShooterCharacter class is already placed in the MyBPShooter folder:

Figure 1.20 – The converted MyBPShooter C++ project

Figure 1.20 – The converted MyBPShooter C++ project

You may have noticed that some other files, such as MyBPShooterGameMode are missing, in comparison with the MyShooter project. That is because the Blueprint versions already exist, so the corresponding C++ versions are not automatically generated. You can choose to manually convert those blueprints to C++ classes only when necessary; otherwise, you just keep the blueprints.

Previous PageNext Page
You have been reading a chapter from
Unreal Engine 5 Game Development with C++ Scripting
Published in: Aug 2023Publisher: PacktISBN-13: 9781804613931
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
ZHENYU GEORGE LI

Zhenyu George Li is a passionate video game developer with 20+ years of experience. He has contributed significantly to many games and serves as a senior development consultant at Unity. His early immersion in technologies like C/C++, DirectX, OpenGL, and Windows GUI laid the foundation for his success. Notable titles in his portfolio include Magic Arena, Halo Infinity, Stela, Dead Rising 2, and The Bigs 2. He has gained extensive knowledge in programming, graphics, animation, gameplay, AI, multiplayer, and UI using Unreal and Unity engines. Additionally, he has taught UE at Vancouver Film School and has college teaching experience at College of Interactive Arts and Hefei Union University.
Read more about ZHENYU GEORGE LI