0

I have a little code snippet in UE4 c++ that is supposed to give me a bunch of FVectors in a grid.

However, printing out the FVectors gives me (0,0,0) every single time

FVector deltaLoc;
float xGap = 150;
float yGap = 150;

for (int i = 0; i < rows; i++) {
    //FCellRow row;
    for (int j = 0; j < columns; j++) {
        UE_LOG(LogTemp, Warning, TEXT("I, J:  %f, %f"), i, j);
        UE_LOG(LogTemp, Warning, TEXT("newX, newY:  %f, %f"), xGap * i, yGap * j);
        deltaLoc.Set(xGap * i, yGap * j, 0);
        
        //deltaLoc.X = xGap * i;
        //deltaLoc.Y = yGap * j;
        UE_LOG(LogTemp, Warning, TEXT("DeltaLoc %f %f %f"), deltaLoc.X, deltaLoc.Y, deltaLoc.Z);
}

The output looks like

LogTemp: Warning: I, J: 0, 2

LogTemp: Warning: newX, newY: 0, 300

LogTemp: Warning: DeltaLoc 0 0 0

for all values of i and j. The first two log lines work fine. The third one stays the same.

Community
  • 1
  • 1
  • I can't tell you this is the problem for certain but it's at-least a problem. `UE_LOG` ends up casting to the stated type, on the first two logs YOU are printing int s and suggesting they're floats which is not legal. – George Apr 13 '20 at 08:10
  • That seems to be the issue I was facing. Using the correct types in log message helps. – Shrey Ghildiyal Apr 13 '20 at 15:07

0 Answers0