Hello, I would like to ask you for help with a crash problem.
My code compiles with no issues, but when I try to call it, the game crash, because:
Array index out of bounds: 0 from an array of size 0.
I have checked that all of the input arrays have the same length (400).
I tried the rebuild solution stated here: [link text][1], but it did not work.
Any idea what could be causing it?
The code of the problematic function is:
void UOperaceSeStverci::C_Vapor(TArray<float> Hummidity, TArray<float> FreeWater, TArray<float> Temperature, float VaporRate, TArray<float>& NewHummidity, TArray<float> & NewFreeWater)
{
float ToVapor;
float a;
float b;
float water;
TArray<float> T;
float vapored;
TArray<float> H;
TArray<float> FW;
TArray<float> NH;
TArray<float> NFW;
T = Temperature;
H = Hummidity;
FW = FreeWater;
a = -0.00045; // constants calculated for linear regresion - approx 5% for 24 hour with averange temperature 0°C and 21% for averange 20°C.
b = 0.989;
for (int i = 0; i != T.Num(); ++i)
{
ToVapor = VaporRate * a * T[i] + b;
if (FW[i] == 0)
{
NH[i] *= ToVapor;
NFW[i] = 0;
}
else
{
water = H[i] + FW[i];
vapored = water * ToVapor;
FMath::Clamp(vapored, 0.0f, H[i] * ToVapor);
if (vapored <= FW[i])
{
NH[i] = H[i];
NFW[i] -= vapored;
}
else
{
NFW[i] = 0;
NH[i] = H[i] - vapored + FW[i];
}
}
NH[i] = floor(NH[i]);
NFW[i] = floor(NFW[i]);
}
NewHummidity = NH;
NewFreeWater = NFW;
}
This is how I call it in the blueprint (GameState class):
The full error message is :
Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:C:\Program Files\Epic Games\UE_4.26\Engine\Source\Runtime\Core\Public\Containers/Array.h] [Line: 674] Array index out of bounds: 0 from an array of size 0
UE4Editor_Core
UE4Editor_Core
UE4Editor_PokusySeCtverci_4003!DispatchCheckVerify >() [c:\program files\epic games\ue_4.26\engine\source\runtime\core\public\misc\assertionmacros.h:165]
UE4Editor_PokusySeCtverci_4003!UOperaceSeStverci::C_Vapor() [c:\hryl\unreal\pokus_ctvercovasit\pokusysectverci\source\pokusysectverci\operacesestverci.cpp:178]
UE4Editor_PokusySeCtverci_4003!UOperaceSeStverci::execC_Vapor() [c:\hryl\unreal\pokus_ctvercovasit\pokusysectverci\intermediate\build\win64\ue4editor\inc\pokusysectverci\operacesestverci.gen.cpp:133]
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Core
UE4Editor_Core
UE4Editor_Core
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
kernel32
ntdll