[UE4]acotor放置4*4列表
// Number of blocks const int32 NumBlocks = Size * Size; // Loop to spawn each block for(int32 BlockIndex=0; BlockIndex<NumBlocks; BlockIndex++) { const float XOffset = (BlockIndex/Size) * BlockSpacing; // X坐标 const float YOffset = (BlockIndex%Size) * BlockSpacing; // Y坐标 // Make postion vector, offset from Grid location const FVector BlockLocation = FVector(XOffset, YOffset, 0.f) + GetActorLocation(); // Spawn a block APuzzleBlock* NewBlock = GetWorld()->SpawnActor<APuzzleBlock>(BlockLocation, FRotator(0,0,0)); // Tell the block about its owner if(NewBlock != NULL) { NewBlock->OwningGrid = this; } }