Cast blueprint class to c++

I have a Character implemented in Blueprint, and I need to get reference to it in a C++ Actor.

The Actor has a BoxComponent and an OnOverlapBegin(class AActor OtherActor, class UPrimitiveComponent OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)** function that will do something when the Character overlaps it. So, I need to find a way to Cast the OtherActor that overlaped the BoxComponent to my Character Blueprint class. Is that possible? If so, how can I do that?

You can’t, you blueprint class is a data that is loaded on runtime, it does not exist in native code, you can access it by retrieving UFunctions and UProperties, but won’t be able to use it same as C++ classes. But there many ways to walkaround it, most basic solution is to create bade class of ACharacter with C++ code and make blueprint based if it to implement blueprint part of it. You need to fully explain what you want to do.

Ok then. Thanks for the answer, .

The Actor was supposed to be a “Wind Mechanical”. When the Character is in the BoxComponent and jumping, the Wind would push him to some side. Simple as that. This is what I was doing until I realize that I couldn’t Cast the Blueprint Character Class:

void AWind::OnOverlapBegin(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
	if (OtherActor && (OtherActor != this) && OtherComp)
		// Cast OtherActor to the Character Blueprint Class here

		if (TestChar && !TestChar->IsPendingKill()) // TestChar is the Casted Actor
			bIsActive = true; // Turns the Wind On

But as you said I can’t cast the Blueprint Class, I’ll have to try another way.

The problem of creating a base C++ class of the Character is that the project is already too big (and everything is implemented in Blueprints), and if I do this to the Character, I would have to do it for a lot of other Pawns and Actors (or maybe all of them), and it would take weeks!

You said there are other ways to walkaround the problem. What else can I do?

Hmm you could try using overlap delegates, but you would need other function to bind it from blueprint on BeginPlay. You can also change parent class of already existing blueprints in “Blueprint Props”

Yeah, that could certainly work! Thanks for your answer! But I can’t do it, because if I do lots of mechanics for the game, the Character Blueprint would have a lot of things binded. I’ll have to keep the project in blueprints.