I want to running C++ code whenever my actor`s location is changed.
So i Created my code in Onconstructor function to define my code
In OnConstructor code
void AChunk::OnConstruction(const FTransform& Transform)
{
Super::OnConstruction(Transform);
UpdateChunk();
}
.void AChunk::UpdateChunk()
{
GenerateChunk();
UE_LOG(LogTemp, Log, TEXT("Vertics Array Num = %d , Triangles Array Num = %d"), Vertics.Num(), Triangles.Num());
if (Vertics.Num() > 0)
{
Vertics.Empty();
}
if (Triangles.Num() > 0)
{
Triangles.Empty();
}
int index = 0;
for (int z = 0; z < ChunkZElements; z++)
{
for (int y = 0; y < ChunkLineElements; y++)
{
for (int x = 0; x < ChunkLineElements; x++)
{
index = x + y * ChunkLineElements + z * ChunkLineElementsP2;
if (ChunkField[index] > 0)
{
if (x - 1 >= 0 && ChunkField[index - 1] == 0)
{
AddLeftXFace(x - 1, y, z);
}
if (y - 1 >= 0 && ChunkField[index - ChunkLineElements] == 0)
{
AddRightYFace(x, y - 1, z);
}
if (z - 1 >= 0 && ChunkField[index - ChunkLineElementsP2] == 0)
{
AddTopFace(x, y, z - 1);
}
if (x + 1 < ChunkLineElements && ChunkField[index + 1] == 0)
{
AddRightXFace(x + 1, y, z);
}
if (y + 1 < ChunkLineElements && ChunkField[index + ChunkLineElements] == 0)
{
AddLeftYFace(x, y + 1, z);
}
if (z + 1 < ChunkZElements && ChunkField[index + ChunkLineElementsP2] == 0)
{
AddBottomFace(x, y, z + 1);
}
}
}
}
}
MeshCreator->ClearAllMeshSections();
MeshCreator->CreateMeshSection(0, Vertics, Triangles, Normals, UVs, VertexColor, MeshTangents, true);
}
It results Absolutely Nothing… So im trying to checked how many times run the code Onconstructor code and it seems so many times running that code.. that
s problem i guess but i don`t know how to figure it out Help me
by the way im not good at english pls don
t look it bad