[Bug] Type Mismatch when casting to own type in a Blueprint

Hello folks,

Background

I’ve made an AnimNotify blueprint. I’ve implemented the Received_Notify event, and inside that I have need to compare the currently triggered AnimNotify (the one processing the event) to the other AnimNotifys on the AnimSequence.

To do this, I had to write a few static pure getter functions to retrieve the properties of the AnimNotifyEvents because the UPROPERTY fields, while C++ public, are not blueprint exposed. All of this works as expected, except when I need to cast the AnimNotify* on each AnimNotifyEvent to their blueprint type for field comparison.

Problem

The cast exposes the casted-object as [object’ActionEvent_C’], the compiled type of the blueprint calling the cast [‘ActionEvent’]. If I drag the pin out to create a node, it will let me create a get-field node context sensitively. If I then try to compile the blueprint, it complains about a type mismatch between the casted-object pin and the get-field target pin:

Error 'Type mismatch between pins Target and AsActionEvent_C'

Hello Andrew,

I’m not able to reproduce the issue. So it was already fixed in the main branch (hopefully) or the problem is more specific.
Is there a way to reproduce the issue without changing the native code?

Cheers,
M

Hello Maciej,

I put together some reproduction steps for you. In this case I’m using a single BlueprintPure UFUNCTION to simplify matters, but I have tested with some AActor returning engine methods and the problem still occurs with those. Notably, the problem only exists in blueprint functions (both custom and implemented events); I could not replicate it on the event graph.

Here is the UFUNCTION you will need:

UFUNCTION(BlueprintPure, Category=Testing)
static UAnimNotify* GetNotify();

...

UAnimNotify* ASandboxGameMode::GetNotify()
{
	return 0;
}

The fact that it returns a null pointer is not an issue (I have tested with proper return values), it is just a simplification for the purposes of this reproduction.

Here are the steps:

  1. Create an AnimNotify blueprint. In this case, I have named it TestNotify.
  2. Implement the Received_Notify method.
  3. Add a bool variable to the blueprint. In this case, I have named it TestVar.
  4. Compile.
  5. Set up the nodes like in the picture below. It will result in the displayed error when you compile again.

Now is where the weird stuff happens. There is a way to get it working. Delete the Cast node in the middle and link the execution paths. Compile, and you will have a graph like this:

Finally, add the Cast node back in and relink like earlier.

Very strange.

Hello Andrew,

Thank you for the detailed repro steps. It looks like the issue was already fixed.
In next QA Build the problem should not occur.

Cheers,
M

Thank you.

Can you post your actual code please?

Rama

There isn’t any related code outside of the blueprint. Here’s a pic of the error.

bp_error_casting.png