ToonTanks - Using Dynamic Delegates (147) - Projectile doesn't destroy

In the section Using Dynamic Delegates for ToonTanks, we code the destruction of the projectile once it hits something. Exept that for me, projectiles aren’t destroyed.

At first, I though I had coded incorrectly. So I copied the relevant code from the Github commit, recompiled and…no happiness.

If I go into the projectile blueprint, I can bring in the event and wire ti to destroy when it hits something, but that isn’t how its supposed to work, and according to the lecture, can create problems when when the base component is used differently.

Anybody else running into this issue? Any solutions?

Did you compile with the editor open?

Yes. Then compiled again without. Still didn’t get the expected result. I’ve compiled and recompiled, both with and without the editor open. Stil, projectile only disappear after a few seconds.

I didn’t realise this was the issue. That would be due to SetInitialLifeSpan.

Hi @DanM,

could you elaborate more here?

I have the exact same issue as the OP:

here is my header file for the Projectile class:

and here is the implementation:

I’ve recompiled multiple times but I cannot get the OnHit function to be called.

Moreover, if I move this line:

ProjectileMesh->OnComponentHit.AddDynamic(this, &AProjectileBase::OnHit);

inside the BeginPlay function, as recommended on other posts, unreal crashes as soon as you fire a projectile:

Assertion failed: DelegateOwner->IsValidLowLevelFast(false) [File:C:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\CoreUObject\Public\UObject/SparseDelegate.h] [Line: 196]

Any Ideas why this is happening?

I think I misunderstood the Jeff twice. You should be able to recreate the blueprint to get it to work or move the delegate binding to BeginPlay (as you’ve said). Not sure about that assertion :confused: is the projectile blueprint to spawn set?

wow @DanM,

Recreating the blueprint actually solved all the issues in one go.

Can I ask you why would recreating the BP fixes these kind of issues?
It is becasue we are spawing that BP when we fire?

It is probably a bug in the engine and/or HotReload.

Say you have this class

class AMyActor : public AActor
{
    UPROPERTY(EditAnywhere)
    int32 Test;
public:
    AMyActor() { Test = 3; }
};

And then you make a blueprint based off of AMyActor, if you were to change the constructor to bd

AMyActor() { Test = 10; }

That won’t be reflected in the blueprint. Instead you’ll get a yellow arrow to be able to reset it to the default value which is now 10.

Consider having the blueprint the way you want and then update engine version where AActor changed a default value. You probably don’t want to have your blueprint modified from under you to use this new default. So that’s all you would get, a yellow arrow.

So this is what most likely happened. The problem with that is it doesn’t really make sense for delegates, there’s no way (as far as I know) to “reset to the default” in blueprint for this.

Awesome,

thank you for the clarification and the fast reply :slight_smile:

hey just a question? how do i recreate the blueprint?

Delete it and follow the same steps you did when you first created it.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms