OnComponentHit.AddDynamic() is not available for me in Unreal

I’m using UE 4.12.5. The same version as in the video but I could not find the method with the given name/signature. Probably it’s related to the fact that I’m doing the course much later that the video was recorded. I don’t know. Here is what I can see in VS:

I’ve found a way to use the add method like this:

void UTankTrack::BeginPlay()
{
	FScriptDelegate ScriptDelegate;
	ScriptDelegate.BindUFunction(this, FName("OnHit"));
	OnComponentHit.Add(ScriptDelegate);
}

I don’t know if it’s the intended way to generate OnHit events but it works for me.
Actually the following code works as well. I’m just a bit hesitant to use the function that is prefixed with __Internal. It looks like they don’t want the clients to use it directly.

OnComponentHit.__Internal_AddDynamic(this, &UTankTrack::OnHit, FName("OnHit"));

What do you think of the FScriptDelegate approach? Am I doing things correctly here?

3 Likes

I figured the problem out while working on the delegates challenge. AddDynamic is a macro which is not displayed by IntelliSense. It works fine though. Things like this may be very confusing when you’re used to rely on your IDE’s hints. I’m used to working with Java, and I don’t really get into situations like this.

void UTankTrack::BeginPlay()
{
OnComponentHit.AddDynamic(this, &UTankTrack::OnHit);
}

4 Likes

Ah nice! Thanks buddy, I was wondering where that was!

Thanks! That helps me a lot~

Privacy & Terms