C++ interface in my anim blueprint causes the editor to freeze

Or more specifically, once I call a function through C++.

I am currently following Crocopede’s tutorial on edge climbing, with the major change that I am trying to convert his blueprints to C++. I managed to get to the part where I call the interface to say to the blueprint that it can grab ledges.

I followed a bunch of tutorials, got the C++ interface to compile without problems, made my own anim blueprint class so I could include the interface. I reparented the anim blueprint in the editor to my new custom class and so far so good; the interface functions are turning up as they should. The problem happens when I try to call a function; the moment I do so, the editor freezes. I am guessing a NULL pointer, but I have no idea why.

The code:

Interface .h


UINTERFACE(MinimalAPI)
class UBK_PS_EdgegrabbingInterface : public UInterface
{
	GENERATED_UINTERFACE_BODY()
};

class IBK_PS_EdgegrabbingInterface
{
	GENERATED_IINTERFACE_BODY()

	UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "Can Grab Ledge"))
		void CanGrabLedgeInterface(bool bCanGrab);
}; 

Anim Instance.h


#pragma once

#include "Animation/AnimInstance.h"
#include "BK_PS_EdgegrabbingInterface.h"
#include "BK_AnimInstance_Player.generated.h"

/**
 * 
 */
UCLASS()
class BURROWOFTHEBEASTKING_API UBK_AnimInstance_Player : public UAnimInstance, public IBK_PS_EdgegrabbingInterface
{
	GENERATED_BODY()
};

And the code responsible for calling the function inside of the anim instance blueprint (done in a Character derived class);


UBK_AnimInstance_Player* AnimInstance = Cast<UBK_AnimInstance_Player>(GetMesh()->GetAnimInstance());
if (AnimInstance)
	AnimInstance->CanGrabLedgeInterface(true);

I have doublechecked whether the instance returns a NULL pointer, but this isn’t the case. The anim instance returned is the assigned blueprint class. I also doublechecked the parent through logging and it is the custom anim class as it is supposed to be. When working in the anim blueprint I can call the CanGrabLedgeInterface event without any problems (it also shows the interface icon properly). It is just that when I call the event in C++, the game crashes.

Nevermind, I already found the root of the issue. I completely did the calling the function part wrong.

Rather than


UBK_AnimInstance_Player* AnimInstance = Cast<UBK_AnimInstance_Player>(GetMesh()->GetAnimInstance());
if (AnimInstance)
	AnimInstance->CanGrabLedgeInterface(true);

I needed to use


UBK_AnimInstance_Player* AnimInstance = Cast<UBK_AnimInstance_Player>(Owner->GetMesh()->GetAnimInstance());
if (AnimInstance)
{
	if (AnimInstance->GetClass()->ImplementsInterface(UBK_PS_EdgegrabbingInterface::StaticClass()))
		IBK_PS_EdgegrabbingInterface::Execute_CanGrabLedgeInterface(AnimInstance, true);
}