try
void UMagicComponent::UseSpellWithCast()
{
if(GetOwner() != nullptr)
{
if (GetOwner()->GetClass()->ImplementsInterface(UINF_MainChar::StaticClass())) {
GetWorld()->GetTimerManager().SetTimer(MyTimerHandle, this, &UMagicComponent::Casting, 2.0f, false);
if(CastWidget != nullptr)
{
CastWidget->AddToViewport();
}
IINF_MainChar::Execute_StartCasting(GetOwner());
bCanDoMagic=false;
}
}
}