

This function is the constructor, and it tells the class how to initialize itself when it is first created. VisualMesh->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f)) Static ConstructorHelpers::FObjectFinder CubeVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Cube.Shape_Cube")) VisualMesh->SetupAttachment(RootComponent) VisualMesh = CreateDefaultSubobject(TEXT("Mesh")) If((USceneComponent* ExistingRootComponent = GetRootComponent()) Now open FloatingActor.cpp and add the following code inside of AFloatingActor::AFloatingActor(), just before the closing bracket:

Note that it uses a UProperty macro, which makes it visible inside the Unreal Editor.įor more information on UProperty and its specifiers, see the page on Properties.

Here we're declaring a StaticMeshComponent, which will act as our visual representation for our object. You can think of it as being sort of like a table of contents for a C++ class.īefore we can start building any new functionality, we must declare any new Variables or Functions that we're using in this file.Īdd the following code underneath the declaration for AFloatingActor(): In our project, it will be located under Games > QuickStart > Source > QuickStart.ĭouble-click FloatingActor.h to open it and bring it into focus in the text editor. In Visual Studio, locate the Solution Explorer, which by default is on the left side of the window, then use it to locate FloatingActor.h. Now that we have created our C++ Class, we're going to switch over to Visual Studio and edit our code.
