So in my Character header file i have these lines:
float testfloat;
void UpdateTeamColors(UMaterialInstanceDynamic* UseMID);
UPROPERTY(Transient)
TArray<UMaterialInstanceDynamic*> MeshMIDs;
void TeamColorVerify();
in the Character cpp file i have this:
//in constructor
testfloat = 0.f;
//and these functions
void ASmashyCharacter::UpdateTeamColors(UMaterialInstanceDynamic* UseMID)
{
if (UseMID)
{
ASmashyPlayerState* MyPlayerState = Cast<ASmashyPlayerState>(PlayerState);
if (MyPlayerState)
{
float MaterialParam = (float)MyPlayerState->GetTeamNum();
UseMID->SetScalarParameterValue(TEXT("TeamColorIndex"), MaterialParam);
}
}
}
void ASmashyCharacter::UpdateTeamColorsAllMIDs()
{
for (int32 i = 0; i < MeshMIDs.Num(); ++i)
{
UpdateTeamColors(MeshMIDs*);
}
}
void ASmashyCharacter::TeamColorVerify()
{
ASmashyPlayerState* MyPlayerState = Cast<ASmashyPlayerState>(PlayerState);
for (int32 i = 0; i < MeshMIDs.Num(); ++i)
{
UpdateTeamColors(MeshMIDs*);
testfloat += 1.f;
UMaterialInstanceDynamic* MI = UMaterialInstanceDynamic::Create(Mesh->GetMaterial(0), this);
MI->SetScalarParameterValue(TEXT("TeamColorIndex"), testfloat);
//float MaterialParam = (float)MyPlayerState->GetTeamNum();
//MeshMIDs*->SetScalarParameterValue(TEXT("TeamColorIndex"), testfloat);
}
}
Here’s the problem. if i create a breakpoint at the start of UpdateTeamColorsAllMIDs(), it breaks, so the function is being run. it also breaks if i place a point at the start of the for loop.
If i place a break point inside the for loop (UpdateTeamColors(MeshMIDs*);), this break point is never triggered.
So then i set up the final function just to see if i could debug this somewhat. TeamColorVerify() is triggered by a button press (e). placing breakpoints within the function confirms that it’s being triggered fine. EXCEPT for within the for loop, the same line fails to trigger the break point as in the previous function.
Also, annoyingly… TeamColorVerify() doesn’t seem to adjust the TeamColorIndex parameter within the material that’s applied to the character mesh.
This means i have two problems. The first is that for some reason the function within the for loop is never triggered (super frustrating). And also the parameter isn’t changed either. This is still the case if i uncomment the bottom two lines in TeamColorVerify().
Any ideas?