Hi, what’s the purpose of the automatically created header file having two “public:” areas of member definitions? Like so
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"
UCLASS()
class TRICKCANNON_API AMyActor : public AActor
{
GENERATED_BODY()
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;
};
Are the same? Can function definitions be put in either one and work all the same? Can one of them be deleted?
I don’t know why the template is written in that way but you can move things around as you want.
public:
// Sets default values for this actor's properties
AMyActor();
// Called every frame
virtual void Tick(float DeltaTime) override;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
Or:
public:
// Sets default values for this actor's properties
AMyActor();
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called when the game starts or when spawned
virtual void BeginPlay() override;
Just remember the rules of the protection levels:
Public: any class can access.
Protected: classes derived from this class can access.
Private: only this class can access.