Hi i’m new to unreal and trying to learn how to use it.
for my first unreal practice project, i want to make simple grid based game.
so i watch this live training video and trying to convert blueprint into c++. (link on “this”)
i hardly understood how to use UPROPERTY and now my code is
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "BasicGrid.generated.h"
class UInstancedStaticMeshComponent;
UCLASS()
class TURNBASED_API ABasicGrid : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ABasicGrid();
//~ABasicGrid();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
private:
UPROPERTY(EditAnywhere, Category = "GridSetting")
int64 m_iGrid_X = 16;
UPROPERTY(EditAnywhere, Category = "GridSetting")
int64 m_iGrid_Y = 16;
UPROPERTY(EditAnywhere, Category = "GridSetting")
int64 m_iGrid_Size = 100;
//UPROPERTY(EditAnywhere, Category = "GridSetting")
// UInstancedStaticMeshComponent* m_pComponent_InstancedStaticMesh = nullptr;
};
it is my header file and it is all i have done ;D
i want to use Instanced Static Mesh to visualize the grid.
but the book i read said, i can use TSubobjectPtr to save pointer.
and idk what subobject but after some searching i thought it’s like component and TSubobjecPtr is like SmartPointer which delete it automatically without manual delete.
it seems TSubobjectPtr is old and no longer supported method and i should use FSubobjectPtr thing but i really can’t find well explained doc about it. so i want to old classic C++ way to handle pointer.
but the problem is i can’t figure out how i properly call destructor and when i should clear it’s data.
when i debugged, ~ABasicGrid() was never called.
and i found few virtual functions that AActor has (BeginDestroy, Destroy, Destroyed) but i’m not sure what i should use and whether i should call parent’s destroy function or unreal automatically call some how.
so i’m so confused and don’t know how to start it. because i don’t know how to clear what i made
can someone explain how to properly use destroy function or destructor on unreal engine?