Casting Interface to Pawn subclass in Blueprint causes massive crash

So I guess that Interfaces aren’t supposed to be cast-able? I don’t know. That doesn’t make sense to me, but based on what it takes to repro this, I’m assuming that’s case.

Approximate Repro:
Make Blueprint Interface (IHero we’ll call this)
Make player pawn that implements above interface (we’ll call it Hero)

Make a new blueprint, (TestCrash in this case)

In TestCrash make a variable, “HeroInterface” that is of type IHero.

In Event Graph, make a [Event Begin Play] node. Drag [Get HeroInterface] onto graph.

(This is part that leads me to believe interfaces aren’t supposed to be cast-able.)
Make a [Get Player Pawn] node. Drag Pawn pin to make a [Cast to Hero] node. Delete [Get Player Pawn], and connect [Cast to Hero] to [Event Begin Play] so that you have
[Event Begin Play] – [Cast to Hero]

Connect HeroInterface to Object pin on [Cast to Hero]. Hit save, then hit compile.

Expected Result:
Probably some kind of error? Personally, my expect result is that it works, because why shouldn’t it?

Actual Result:
A crash so hard it will bruise your mother. Not only does it crash Editor, but if editor wants to open that blueprint on load, it will crash on project load. If you open Editor then drag Blueprint into folder via Windows Explorer, if you attempt to open blueprint it will crash again. So only way to fix this problem is to delete or otherwise get rid of blueprint and start over with it. Which is, you know, inconvenient.

I should mention as well that I did not actually repro this from a new scratch project. If you can’t repro, let me know and I will try from scratch.

Hey apollyonbob,

I was able to reproduce this issue and have entered a bug report for developers to look over (TTP# 349716).

cause is attempt to Cast to a Blueprint off of a Interface variable that shouldn’t be able to accept Interface. bug is that what you’re attempting to cast to shouldn’t be able to accept interface variable as an input at all. Can you explain what you’re attempting to do with interface? Interfaces allow you to communicate between blueprints, so if both your TestCrash BP and your Hero BP use IHero interface, you shouldn’t need to cast to character at all. If you do prefer to cast to character, you can do so using Get Player Pawn or similar references, rather than use a reference to interface, which is not a parent of pawn.

You can read more about interfaces here:

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/Interface/index.html

Let me know what setup you’re looking to achieve and I’ll try to show you how to do it.

Oh I was doing bad things haha. I appreciate thought though! To explain briefly, I had originally passed an interface instead of entire hero because I thought all I needed was interface. I cast Interface back to Hero on other side basically because I was being a little lazy before going back and changing interface. I ended up doing things a lot different in end.

It was catastrophic crash and inability to open project that I wanted to call attention to haha.

Also yes, I mean, I realize I mentioned that I would expect that to work, but that was definitely programmer side of me. architect side of me says that it shouldn’t ever be done - and I had no intention of keeping code that way. But I guess I figured with the “Cast Failed” pin you guys were already taking bad casts into account. difficulty in getting cast node to begin with should’ve been a warning sign haha, but I’m still figuring Blueprints out.

Thanks for response though! Appreciate it.