Where can I find the BeginPlay in the Character Class?

I am currently following a tutorial on importing a weapon into UE4. I have the basics down, however when I play the editor, the weapon is pointing straight up. The uploader then posted a solution saying to find the BeginPlay in the Character Class, and I can’t find it. Any helps on this dilemma?

Unreal Engine C++ Tutorial - Making a gun! - YouTube This is the tutorial I am following

Without having watch the video, you can find BeginPlay in the following cases.

BLUEPRINTS

You can find BeginPlay in any blueprint you create by right-clicking anywhere on the graph and typing in “Begin Play”. This will cause the contextual menu to display the “Begin Play” event node. Clicking on it will cause the node to appear in the graph, at which point you can pin it up to whatever methods you need to run.

It is recommended that you add a call to the parent function as well. To do this, right-click on the Begin Play event node and select “Add call to parent function”. If it is grayed out and unselectable you do not need to worry about it.

When the uploader said “Find the BeginPlay in the character class”, it means finding this node. If you type “Begin Play” in the context menu and click on the result, if the event node already exists it will take you to that node.

C++

To create the BeginPlay method in a C++ class you would add the following code.

In your character’s header file add the following line:

virtual void BeginPlay() override;

“Virtual” indicates that the method can be overridden in child classes. “void” is the return type - void meaning the method does not return anything. “override” indicates that it is “replacing” the method call of a parent method which uses the aforementioned “virtual” keyword.

In your character’s cpp file add the following code:

void AMyCharacterClass::BeginPlay()
{
    Super::BeginPlay();
}

“void” once again indicates that the method does not return anything. This needs to match the return type specified in the header. “AMyCharacterClass::” indicates that the method belongs to the specified class. “BeginPlay()” is the name of the method.

The “Super::BeginPlay()” line indicates that we want to call the parent’s version of this method. If you recall we specified in the header that we are “replacing” the parent’s method call. It is not specifically that it is replaced, but it is being called instead of the other method. Here we are making a call to the other method to ensure it executes. We can then add custom functionality afterwards.

void AMyCharacterClass::BeginPlay()
{
    Super::BeginPlay();

    DoCustomEvents();
    CauseSuperMassiveExplosion();
}

When the uploader said “Find the BeginPlay in the character class”, it means finding the implementation of this code.

He is using a pre-built character in his example. Notice how the FP_Gun is a sub component to his character when he’s changing it out for the his custom weapon.
I don’t know if this video was based off of previous project work; where he may have already setup that custom character, or if he is working from an Epic provided project (like Shooter Game).

Either way; “BeginPlay” is an event that you should be able to access from most any BluePrint objects (typically children Actor Classes) within UE.
If you open the BluePrint for character (or gun object, which ever you’re searching for); go to the Event Graph for that object.
If you do not see an existing “Begin Play” event, you can:

  1. Right click anywhere on the graph background
  2. Search for “BeginPlay”
  3. Select “Event Begin Play” under the section “Add Event”