In actor cpp file, I made triggers in constructor.
a part of code is:
Trigger = CreateDefaultSubobject<UBoxComponent>(TEXT("TRIGGER"));
Trigger->SetBoxExtent(FVector(775.0f, 775.0f, 300.0f));
Trigger->SetupAttachment(RootComponent);
Trigger->SetRelativeLocation(FVector(0.0f, 0.0f, 250.0f));
Trigger->SetCollisionProfileName(TEXT("ABTrigger")); // This works.
Trigger->OnComponentBeginOverlap.AddDynamic(this, &AABSection::OnTriggerBeginOverlap);
static FName GateSockets[] = { { TEXT("+XGate") }, { TEXT("-XGate") }, { TEXT("+YGate") }, { TEXT("-YGate") } };
for (FName GateSocket : GateSockets)
{
ABCHECK(Mesh->DoesSocketExist(GateSocket));
UStaticMeshComponent * NewGate = CreateAbstractDefaultSubobject<UStaticMeshComponent>(*GateSocket.ToString());
NewGate->SetStaticMesh(SM_GATE.Object);
NewGate->SetupAttachment(RootComponent, GateSocket);
NewGate->SetRelativeLocation(FVector(0.0f, -80.5f, 0.0f));
GateMeshes.Add(NewGate);
UBoxComponent * NewGateTrigger = CreateDefaultSubobject<UBoxComponent>(*GateSocket.ToString().Append(TEXT("Trigger")));
NewGateTrigger->SetBoxExtent(FVector(100.0f, 100.0f, 300.0f));
NewGateTrigger->SetupAttachment(RootComponent, GateSocket);
NewGateTrigger->SetRelativeLocation(FVector(70.0f, 0.0f, 250.0f));
NewGateTrigger->SetCollisionProfileName(TEXT("ABTrigger")); // Not work!!
GateTriggers.Add(NewGateTrigger);
NewGateTrigger->OnComponentBeginOverlap.AddDynamic(this, &AABSection::OnGateTriggerBeginOverlap);
NewGateTrigger->ComponentTags.Add(GateSocket);
}
What’s wrong?
± X Y Gate, when I’m on confirmation, their collision preset name is “NoCollision”
How can I fix this? I removed entire code, re-wrote, and re-compiled, but it still not works…
Thank you.