Add mesh to GridCell

This commit is contained in:
yuichipanda committed 2026-11-01 17:54:41 +09:00
1 parent 57065dc6cb
commit c51138b0f1
152 files changed
+183 -149

No files matched your search

+20 -1
View File
@@ -1,7 +1,26 @@
#include "GridCell.h"
#include "Components/StaticMeshComponent.h"
#include "Engine/StaticMesh.h"
#include "UObject/ConstructorHelpers.h"
AGridCell::AGridCell()
{
// ターン制では毎フレームの処理が不要なので、Tickを無効にする
PrimaryActorTick.bCanEverTick = false;
// コンポーネントを作ってルートにする
MeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComponent"));
SetRootComponent(MeshComponent);
// エンジン標準の立方体を読み込む(コンストラクタ内でのみ使える方法)
static ConstructorHelpers::FObjectFinder<UStaticMesh> CubeAsset(
TEXT("/Engine/BasicShapes/Cube.Cube"));
if (CubeAsset.Succeeded())
{
MeshComponent->SetStaticMesh(CubeAsset.Object);
}
// 立方体は100x100x100cm。マス間に少しすき間を空け、厚さ10cmの板にする
MeshComponent->SetRelativeScale3D(FVector(0.95f, 0.95f, 0.1f));
// 板の上面がActorの原点の高さに来るよう、厚さの半分(5cm)下げる
MeshComponent->SetRelativeLocation(FVector(0.0f, 0.0f, -5.0f));
}
+6
View File
@@ -4,6 +4,8 @@
#include "GameFramework/Actor.h"
#include "GridCell.generated.h"
class UStaticMeshComponent;
UCLASS()
class TACTICA_API AGridCell : public AActor
{
@@ -12,6 +14,10 @@ class TACTICA_API AGridCell : public AActor
public:
AGridCell();
// マスの見た目(板状の立方体)
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Grid")
TObjectPtr<UStaticMeshComponent> MeshComponent;
// グリッド上の座標 (X, Y)
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Grid")
FIntPoint GridCoord = FIntPoint::ZeroValue;