Skip to content

Commit

Permalink
spawn cells.
Browse files Browse the repository at this point in the history
  • Loading branch information
wutipong committed Dec 8, 2021
1 parent f2c2dc0 commit 830429d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Binary file modified Content/Maze/ImplCellBP.uasset
Binary file not shown.
2 changes: 0 additions & 2 deletions Source/AMazeUnreal/Cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class AMAZEUNREAL_API ACell : public AActor
virtual void BeginPlay() override;

public:

UPROPERTY(EditAnywhere)
int Id = 0;

UPROPERTY(BlueprintReadWrite, Instanced)
Expand Down
10 changes: 7 additions & 3 deletions Source/AMazeUnreal/Maze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ void AMaze::BeginPlay()

cells.SetNumUninitialized(Count());

int cellWidth = dynamic_cast<ACell*>(Cell.Get())->Width;
int cellHeight = dynamic_cast<ACell*>(Cell.Get())->Depth;
int cellWidth = Cell.GetDefaultObject()->Width;
int cellHeight = Cell.GetDefaultObject()->Depth;

FVector origin;
FVector extent;
Cell.GetDefaultObject()->GetActorBounds(false, origin, extent);

for (int r = 0; r < Rows; r++)
{
Expand All @@ -29,7 +33,7 @@ void AMaze::BeginPlay()
FTransform transform;
transform.SetLocation({ x, y, 0 });

auto cell = GetWorld()->SpawnActor(Cell->StaticClass(), &transform);
auto cell = GetWorld()->SpawnActor(Cell.Get(), &transform);
cells[index] = dynamic_cast<ACell*>(cell);
}
}
Expand Down

0 comments on commit 830429d

Please sign in to comment.