hello i am trying to use the OnComponentBeginOverlap on my door component but its not working here are the code snippets
this is inside constructor
Knob = CreateDefaultSubobject<UDynamicMeshComponent>(TEXT("Knob"));
Knob->AttachToComponent(DynamicMeshComponent,
FAttachmentTransformRules::KeepRelativeTransform);
Knob->OnComponentBeginOverlap.AddDynamic(this, &ADoor::OnKnobBeginOverlap);
This is my Function
void ParentClass::OnKnobBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
FVector A = OtherActor->GetVelocity();
int final = A[0] + A[1] + A[2] / MassOfDoor;
AddActorLocalRotation((FQuat::MakeFromEuler(FVector(0,0,90))), true, nullptr,ETeleportType::None);
}
3dRaven
(3dRaven)
April 1, 2024, 1:36pm
2
GloatingDevil:
Knob
Try this combination in the CDO:
Knob->SetGenerateOverlapEvents(true);
Knob->SetCollisionProfileName(FName(OverlapAll));
Knob->OnComponentBeginOverlap.AddDynamic(this, &ADoor::OnKnobBeginOverlap);
hi sorry for late reply its says : Knob->SetCollisionProfileName(FName(OverlapAll));
undeclared identifier OverlapAll
ok i fixed the above issue by static FName CollisionProfileName(TEXT(“OverlapAll”));
Knob->SetCollisionProfileName(CollisionProfileName);
but the original issue still remains
for some reason this works with main dynamicMeshComponent but not with the knob
Had to include UFUNCTION() before the definition of function in header file
like this
UFUNCTION()
void OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
This will resolve the issue
system
(system)
Closed
May 4, 2024, 7:18am
7
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.