Hi Everyone!
I have three separate classes. DoorBase, ButtonBase, and Oliver (Character class).
I would like to connect the door and button to each other so when the button is pressed, by my character (Oliver) class, the door opens.
So far, I have overlap functionality on my Character class:
Oliver.cpp
void AOliver::OnButtonVolumeBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
AButtonBase* Button = Cast<AButtonBase>(OtherActor);
UBoxComponent* ButtonVolume = Cast<UBoxComponent>(OtherComp);
if (OtherActor == Button && ButtonVolume)
{
bCanPressButton = true;
}
}
void AOliver::OnButtonVolumeEndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
//AButtonBase* Button = Cast<AButtonBase>(OtherActor);
//UBoxComponent* ButtonVolume = Cast<UBoxComponent>(OtherComp);
//if (OtherActor == Button && ButtonVolume)
//{
bCanPressButton = false;
//}
}
void AOliver::ButtonPress()
{
if (bCanPressButton)
{
if (ButtonPressAnimMontage)
{
UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance();
AnimInstance->Montage_Play(ButtonPressAnimMontage);
bCanPressButton = false;
}
}
}
Right now, I’m able to enter the ButtonBase class box volume and that enables my Character class to play an animation. ButtonBase and DoorBase are empty classes at the moment.
My question is how do I connect all 3 classes so that once my Character class interacts ButtonBase, DoorBase plays the open animation?
Thank you in advance!