Hi,
I’m fairly new to C++ and UE4 so please bear with me.
If I’ve created an actor class and I want a message to be displayed on screen or in the output log at the start of the game I simply put
// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
Super::BeginPlay();
// Just to indicate the game and game output log have started
UE_LOG(LogTemp, Warning, TEXT("game started!"));
}
in my .cpp - This outputs the message to the output log correctly at the beginning of the game. Now my question is if I’ve declared another UFUNCTION() in my header like so:
UCLASS()
class MyActor_API MyActor : public AActor
{
GENERATED_BODY()
UFUNCTION(BlueprintCallable, Category = "TCPConnection")
void sendPacket();
public:
// Sets default values for this actor's properties
AMyActor();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
And change the .cpp to
void ACannonBallActor::sendPacket()
{
UE_LOG(LogTemp, Warning, TEXT("game started!"));
}
// Called when the game starts or when spawned
void ACannonBallActor::BeginPlay()
{
Super::BeginPlay();
{
How do I tell Unreal Engine that I want that message to be displayed at the start of the game even though it’s not in BeginPlay()? I know this is a trivial example but I’m just trying to get the basics down and have a thorough understanding.
Thanks in advance
To clarify: After the code is compiled, an instance of the Actor is dragged into the editor from the content browser.