# Having Errors while trying to check if an Actor implements an interface. StaticClass is not a member

**URL:** <https://forums.unrealengine.com/t/having-errors-while-trying-to-check-if-an-actor-implements-an-interface-staticclass-is-not-a-member/211147>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [March 28, 2021, 11:45pm UTC](https://forums.unrealengine.com/t/having-errors-while-trying-to-check-if-an-actor-implements-an-interface-staticclass-is-not-a-member/211147 "2021-03-28T23:45:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ilbeyataberkcan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ilbeyataberkcan](https://forums.unrealengine.com/u/ilbeyataberkcan)\
**Post date:** [March 28, 2021, 11:45pm UTC](https://forums.unrealengine.com/t/having-errors-while-trying-to-check-if-an-actor-implements-an-interface-staticclass-is-not-a-member/211147/1 "2021-03-28T23:45:12Z")

</div>

​

[https://forums.unrealengine.com/core/image/gif;base64](https://forums.unrealengine.com/core/image/gif;base64)

​​​​​ Hi everyone.

I’m looking into this for hours now and couldn’t figured it out. Also couldn’t find anything about it on forums or answerhub. I also tried to open a question on Answerhub but I kept having an error. I really need your help.

In more detail:  
I have created an Interface class so I could get an integer, that represents the FocusPriority, from different classes. But the problem is when I want to check if the class implements the Interface, the functions “Implements()” and “ImplementsInterface()” can’t call StaticClass() function on my interface class. The error says it’s not a member of the class. But as far as I know this function is added by GENERATED\_BODY() Macro. I must have been missing a point; but what?

I’ve created all of my service and revert my changes to recreate everything step by step. Yet the problem persists. I don’t know what to do. I need this Interface to work with Blueprints too; at least for now.

Did any of you had this error before? Please help me. This took longer than it should already

---

<div class="post-metadata">

**Author:** ![Shmoopy1701](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shmoopy1701/32/1194536_2.png) [@Shmoopy1701](https://forums.unrealengine.com/u/Shmoopy1701)\
**Post date:** [March 29, 2021, 1:41pm UTC](https://forums.unrealengine.com/t/having-errors-while-trying-to-check-if-an-actor-implements-an-interface-staticclass-is-not-a-member/211147/2 "2021-03-29T13:41:04Z")

</div>

We use interfaces extensively and just cast to the interface in situations like that.

Not sure that interface check is worth doing since you have to cast the object anyway to do something with it.

```auto

// for each actor in world
for (TActorIterator<AInteractiveActor> ActorItr(GetWorld()); ActorItr; ++ActorItr)
{
    IInteractiveBase* interactiveActor = Cast<IInteractiveBase>(*ActorItr);
    if (interactiveActor != nullptr)
    {
          // do something with object
    }
}

```

---

<div class="post-metadata">

**Author:** ![Levantail](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/levantail/32/88718_2.png) [@Levantail](https://forums.unrealengine.com/u/Levantail)\
**Post date:** [March 29, 2021, 3:26pm UTC](https://forums.unrealengine.com/t/having-errors-while-trying-to-check-if-an-actor-implements-an-interface-staticclass-is-not-a-member/211147/3 "2021-03-29T15:26:51Z")

</div>

Did you have included interface header file to your h/cpp file ?

UPD:  
Also, you probably need static class from U\* prefix name interface class, not from I\* at ImplementsInterface func.

---

<div class="post-metadata">

**Author:** ![ilbeyataberkcan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ilbeyataberkcan](https://forums.unrealengine.com/u/ilbeyataberkcan)\
**Post date:** [March 30, 2021, 3:08pm UTC](https://forums.unrealengine.com/t/having-errors-while-trying-to-check-if-an-actor-implements-an-interface-staticclass-is-not-a-member/211147/4 "2021-03-30T15:08:55Z")

</div>

> [@Levantail](#):
>
> Did you have included interface header file to your h/cpp file ?
> 
> UPD:  
> Also, you probably need static class from U\* prefix name interface class, not from I\* at ImplementsInterface func.

I added my header files. BUT OMG… How did I missed that… Thank so much for pointing that out for me. It’s actually obvious to use the ‘U’ prefixed class but it was 4 am when I had that problem. I’m going to test it when I arrive at home and update this thread.

---

<div class="post-metadata">

**Author:** ![ilbeyataberkcan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ilbeyataberkcan](https://forums.unrealengine.com/u/ilbeyataberkcan)\
**Post date:** [March 30, 2021, 7:27pm UTC](https://forums.unrealengine.com/t/having-errors-while-trying-to-check-if-an-actor-implements-an-interface-staticclass-is-not-a-member/211147/5 "2021-03-30T19:27:34Z")

</div>

As an tested update. The suggestion that is below and given by [Shmoopy1701](https://forums.unrealengine.com/member/129723-shmoopy1701)was the solution I’ve found before and worked. Using the ‘U’ prefixed class to get static class didn’t worked. Also after experimenting with it Casting to interface class is also makes the function call easier for us. Thank you Shmoopy. Didn’t see your reply in the morning, sorry for that.

In internet I saw other tutorials suggesting to use the ‘U’ prefixed class but didn’t work for me. Anyway, thank both of you for replying and helping me finding my way out of this.

> [@Shmoopy1701](#):
>
> We use interfaces extensively and just cast to the interface in situations like that.
> 
> Not sure that interface check is worth doing since you have to cast the object anyway to do something with it.
> 
> ```auto
> 
> // for each actor in world
> for (TActorIterator<AInteractiveActor> ActorItr(GetWorld()); ActorItr; ++ActorItr)
> {
> IInteractiveBase* interactiveActor = Cast<AInteractiveActor>(*ActorItr);
> if (interactiveActor != nullptr)
> {
> // do something with object
> }
> }
> 
> ```

---

<div class="post-metadata">

**Author:** ![BrUnO\_XaVIeR](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bruno_xavier/32/1110230_2.png) [@BrUnO\_XaVIeR](https://forums.unrealengine.com/u/BrUnO_XaVIeR)\
**Post date:** [March 30, 2021, 7:37pm UTC](https://forums.unrealengine.com/t/having-errors-while-trying-to-check-if-an-actor-implements-an-interface-staticclass-is-not-a-member/211147/6 "2021-03-30T19:37:45Z")

</div>

Interfaces can be implemented two ways in Unreal Engine…  
Either a C++ Interface or a UInterface sub-object; so you must check for both:

```auto

const auto & MyInterface = Cast<IMyInterfaceClass>( MyActor );

if (MyInterface)
{

    MyInterface->Execute_OnSomethingHappened(MyActor);

}
else
if ( MyActor->GetClass()->ImplementsInterface(UMyInterfaceClass::StaticClass()) )
{

    IMyInterfaceClass::Execute_OnSomethingHappened(MyActor);

}

```

_Execute\_xxx_ is a generated method from the _BlueprintNativeEvent_ you declared in your IMyInterfaceClass.

---

<div class="post-metadata">

**Author:** ![ilbeyataberkcan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ilbeyataberkcan](https://forums.unrealengine.com/u/ilbeyataberkcan)\
**Post date:** [April 21, 2021, 10:05am UTC](https://forums.unrealengine.com/t/having-errors-while-trying-to-check-if-an-actor-implements-an-interface-staticclass-is-not-a-member/211147/7 "2021-04-21T10:05:34Z")

</div>

Thanks for the tip 🙂 But since I’m sure it’s a UInterface do I need to check for both? If I do why?

Would really appreciate if you could explain. I’m trying to know better ways to use C++.

---

<div class="post-metadata">

**Author:** ![iwingn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@iwingn](https://forums.unrealengine.com/u/iwingn)\
**Post date:** [February 22, 2023, 12:42pm UTC](https://forums.unrealengine.com/t/having-errors-while-trying-to-check-if-an-actor-implements-an-interface-staticclass-is-not-a-member/211147/8 "2023-02-22T12:42:31Z")

</div>

Your Interface must be like this

class UMyInterface : public UInterface  
{  
GENERATED\_BODY()  
//this is UE4’s class  
};

class ABC\_API IMyInterface  
{  
GENERATED\_BODY()  
//this is where your interface function is  
public:  
UFUNCTION(BlueprintNativeEvent)  
void MyFunc1();  
}

The thing is you should use UMyInterface to test instead of IMyInterface like this:  
if(MyActor-\>Implements\< UMyInterface \>())

NOT THIS:  
if(MyActor-\>Implements\< IMyInterface \>())

This thing confuse me all a day 🤬
