Hi everyone
I want to add location of my actor in data table but different values added to data table.
the Actor location is (250,-70,30)(in Pic1) but the values in data table value is different (in Pic2)
anybody knows why this happened?
Actor.h
#pragma once
#include "Wall.h"``
#include "Engine/DataTable.h"
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"
USTRUCT(BlueprintType)
struct FActorInformation : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FVector location;
};
UCLASS()
class UIPCG_API AMyActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AMyActor();
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Animation, meta = (AllowPrivateAccess = "true"))
class UDataTable* ActorInformationData;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
Actor.cpp
#include "MyActor.h"
#include "Wall.h"
#include "UObject/ConstructorHelpers.h"
#include "Engine/StaticMesh.h"
#include "GameFramework/Actor.h"
#include "Runtime/Engine/Classes/Engine/World.h"
#include "Runtime/Engine/Classes/Components/StaticMeshComponent.h "
// Sets default values
AMyActor::AMyActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
static ConstructorHelpers::FObjectFinder<UDataTable> DTBObject(TEXT("DataTable'/Game/NewDataTable.NewDataTable'"));
if (DTBObject.Succeeded())
{
ActorInformationData = DTBObject.Object;
}
}
// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
FString actorname = this->GetName();
Super::BeginPlay();
FActorInformation AF;
AF.location = this->GetActorLocation();
PrimaryActorTick.bCanEverTick = true;
if(ActorInformationData!=nullptr)
ActorInformationData->AddRow("ActorOne", AF);
}
// Called every frame
void AMyActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}