# C++ Interface Type not available for casting in Blueprint

**URL:** <https://forums.unrealengine.com/t/c-interface-type-not-available-for-casting-in-blueprint/693908>\
**Category:** C++\
**Tags:** unreal-engine, UE5-0, UInterface, Blueprint, CPP, question\
**Created:** [November 18, 2022, 6:02pm UTC](https://forums.unrealengine.com/t/c-interface-type-not-available-for-casting-in-blueprint/693908 "2022-11-18T18:02:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tarvish](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tarvish](https://forums.unrealengine.com/u/Tarvish)\
**Post date:** [November 18, 2022, 6:02pm UTC](https://forums.unrealengine.com/t/c-interface-type-not-available-for-casting-in-blueprint/693908/1 "2022-11-18T18:02:57Z")

</div>

Hi,  
I have a C++ Interface which forces the implementing Actor to have a simple Function: `GetSomeComponent` (in this case a component representing a resource like Health or Mana). This function needs to be available in Blueprints so it specifies `UFUNCTION(BlueprintCallable)`.

In order to be a`BlueprintCallable` function the interface specifier needs to be `NotBlueprintable`

And to be able to check in Blueprints that an Actor inplements the interface the specifier ` BlueprintType`.

The interface looks like this:

```auto
UINTERFACE(MinimalAPI, BlueprintType, NotBlueprintable)
class UHealthInterface : public UInterface
{
	GENERATED_BODY()
};

/**
 * Force the implementing class to have / return a Resource Component representing Health.
 */
class GAME_API IHealthInterface
{
	GENERATED_BODY()

public:
        UFUNCTION(BlueprintCallable)
	virtual class UResourceComponent* GetHealthResourceComponent() const = 0;
};

```

So far so good. But the issue is, I can’t cast the `Actor` to the `HealthInterface` type in blueprints, it’s not showing up. In the following example I try to cast in in a Widget Blueprint:

 ![unable to cast to health interface](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/b/3/6b3794f6ea48acccc2edda9edc8f6b9a49ab639e.png)

So now comes the weirdest part:  
I solved the problem somehow by doing the following:

1. removing the interface specifier `NotBlueprintable` as well as the function specifier `BlueprintCallable`
2. compile the project
3. now I was able to get the type cast node:  
 ![type cast node](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/6/1/8619cd22f06c7fce7638efca95db1f9ac8ad4a16.png)
4. problem is now that I can’t (as required) to call `GetHealthResourceComponent()` from blueprints
5. I kept the type cast node in blueprints went back to C++ and added back `NotBlueprintable` and `BlueprintCallable`and compiled
6. went back to blueprints and now I can call the function as wanted from the interface:  
 ![interface cast and function call](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/c/4/3c4ff69986ae006ff17f49520630c79bfbf97e04.png)

My question is, is the thing I want to do valid and it is this an unreal bug if `BlueprintType` and `NotBlueprintable` is used together that the type cast does not show in blueprints?

Or did I just do an evil hack which is not intended to work and falls upon my feet later?

---

<div class="post-metadata">

**Author:** ![Tarvish](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tarvish](https://forums.unrealengine.com/u/Tarvish)\
**Post date:** [November 19, 2022, 2:55pm UTC](https://forums.unrealengine.com/t/c-interface-type-not-available-for-casting-in-blueprint/693908/2 "2022-11-19T14:55:03Z")

</div>

Was able to solve it by changing the order of the `UINTERFACE` specifiers.  
By using `UINTERFACE(NotBlueprintable, BlueprintType)` instead of `UINTERFACE(BlueprintType, NotBlueprintable)`.

So while using `NotBlueprintable` and `BlueprintType` together there order must be this way for the type cast showing up in blueprints.

Tested this for UE `5.0` and `5.1`.

---

<div class="post-metadata">

**Author:** ![machinecommune](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@machinecommune](https://forums.unrealengine.com/u/machinecommune)\
**Post date:** [March 26, 2024, 9:12pm UTC](https://forums.unrealengine.com/t/c-interface-type-not-available-for-casting-in-blueprint/693908/3 "2024-03-26T21:12:19Z")

</div>

This appears to work as well, UE5.3.2:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/d/9/8d9f3e122d9fceae2871e2ffbe5b877ce8aa845a.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/4/9/54991313cda6c179dae4d8fad9af0c20356065bb.png)
