Hi.
(UE 4.27.2)
I try to to make the name of my UInstancedStaticMeshComponent unique by adding a random number to the name. After a lot of testing, I figured out, If if use any random function, the OnComponentHit not return with hit event.
Here is the code, how I tried to generate a random name:
if (GetOwner())
{
FString ownername = GetOwner()->GetName();
uniquename = "_"+ownername;
}
else
{
int random_value = FMath::RandRange(1000, 9999);
uniquename = FString::FromInt(random_value)+"_A";
}
//PrimaryComponentTick.bStartWithTickEnabled = true;
Root = CreateDefaultSubobject< USceneComponent>(TEXT("Root"));
RootComponent = Root;
FString rawsidename = "Instancedchainlink_side" + uniquename;
FName sidename = FName(*rawsidename);
//Instancedchainlink_side = CreateDefaultSubobject<UInstancedStaticMeshComponent>(sidename);
The problem is not the name itself, I copyed and added the string manually (Instancedchainlink_side2893_A) to the name, and the event fired. Even weirder, if I added the number to the random_value variable, it also worked perfectly.
Any idea why is this happen, or any workaround. Maybe an another method to make my Instance name unique?