bWantsBeginPlay & OpenDoor component

  1. What is the significance of the “bWantsBeginPlay” Boolean? This line was not Generated on UE 4.24 and my solution only compiles if this line is not present. See error message below:

Severity Code Description Project File Line Suppression State
Error (active) E0020 identifier “bWantsBeginPlay” is undefined BuildingEscape

  1. Furthermore, the OpenDoor component does not show up in Unreal. I have tried building, and rebuilding my solution in Visual Studio, as well as compiling from Unreal, but alas, no OpenDoor component to be found. Is this possibly related to my first point, or are there any suggestions on a way forward?

Many Thanks…

  1. Was something that existed in earlier versions of UE4 but was deprecated (judging by that message it seems like it’s been removed now?). Apparently it wasn’t really enforced so didn’t do much.

  2. Did you successfully compile? Where are you looking for it?

Hi Dan,

Thanks for your response.

Compilation was successful (after removing the Boolean and moving #include “OpenDoor.h” to the top of my includes, as the compiler insisted on me doing so).

I would expect to see it in the Details tab in Unreal, after selecting the SM_Door.
At least that is where it appears in the tutorial video: 19. Macros Starting with UPROPERTY.

Do you mean when you’re trying to add it to SM_Door? It’s not going to be there if you don’t add it to it.

Apologies… I accidentally posted a reply before completing it…

In Unreal, I followed the steps below:

  1. Select SM_Door.
  2. Add Component
    New C++ Component
    Actor Component
    Named component to “OpenDoor”
    Create Class

It appears to have created OpenDoor.h and OpenDoor.cpp.

// OpenDoor.h
// Copyright Mitch Campbell 2020

#pragma once

#include “CoreMinimal.h”
#include “Components/ActorComponent.h”
#include “OpenDoor.generated.h”

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_API UOpenDoor : public UActorComponent
{
GENERATED_BODY()

public:
// Sets default values for this component’s properties
UOpenDoor();

protected:
// Called when the game starts
virtual void BeginPlay() override;

public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

};

// OpenDoor.cpp
// Copyright Mitch Campbell 2020

#include “BuildingEscape.h”
#include “OpenDoor.h”
#include “GameFramework/Actor.h”

// Sets default values for this component’s properties
UOpenDoor::UOpenDoor()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don’t need them.
PrimaryComponentTick.bCanEverTick = true;

// ...

}

// Called when the game starts
void UOpenDoor::BeginPlay()
{
Super::BeginPlay();

// Find the Owning Actor
AActor* Owner = GetOwner();

// Create a rotator
FRotator NewRotation = FRotator(0.f, -83.f, 0.f);	// floating values are (pitch, yaw, roll) measured in degrees

// Set the door rotation
Owner->SetActorRotation(NewRotation);

}

// Called every frame
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

// ...

}

Could you show your OpenDoor.h?

Sorry for the confusion. I accidentally replied to the last message before I had completed my response.
I posted my OpenDoor.h above.
I have made a number of recent changes changes, and I find that Visual Studio is complaining that it is unable to find OpenDoor.genrated.h :confused:

I am getting the following error:
Severity Code Description Project File Line Suppression State
Error (active) E1696 cannot open source file “OpenDoor.generated.h” BuildingEscape

Please use a code block when pasting code by surrounding it with 3 backticks
```
like so
```
Or using the </> button.

I learn something new everyday :smiley:

// Copyright Mitch Campbell 2020

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "OpenDoor.generated.h"



UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_API UOpenDoor : public UActorComponent
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	UOpenDoor();

protected:
	// Called when the game starts
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

		
};

And you’ve successfully compiled? Could you show a screenshot of what you’re getting in Unreal when adding a component?

Something seems to have changed…Forgive me, but I am new to programming and version control.
It was compiling successfully before, but I am getting the following errors on Visual Studio now:

This is my OpenDoor.cpp:

// Copyright Mitch Campbell 2020


#include "BuildingEscape.h"
#include "OpenDoor.h"
#include "GameFramework/Actor.h"


// Sets default values for this component's properties
UOpenDoor::UOpenDoor()
{
	// Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
	// off to improve performance if you don't need them.
	PrimaryComponentTick.bCanEverTick = true;

	// ...
}


// Called when the game starts
void UOpenDoor::BeginPlay()
{
	Super::BeginPlay();

	// Find the Owning Actor
	AActor* Owner = GetOwner();

	// Create a rotator
	FRotator NewRotation = FRotator(0.f, -83.f, 0.f);	// floating values are (pitch, yaw, roll) measured in degrees

	// Set the door rotation
	Owner->SetActorRotation(NewRotation);
}


// Called every frame
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	// ...
}

Change your Error List to Build instead of Build + IntelliSense. IntelliSense is not going to give you reliable error diagnostics with Unreal.

Changed it, thanks.
After doing so, I tried to compile and got the following error:
image

I moved OpenDoor.h to the first #include and compilation was successful.

This is where I would expect to see the OpenDoor component in Unreal:
image

And when you press Add Component and search for it?

You are a Legend!
Thanks so much :grinning:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms