Projectile Blueprint value is changed to "None". It make a Crash Error in UE (Lecture 164)

Hello Everyone

After I set
UPROPERTY(BlueprintReadOnly)
UTankMovementComponent * TankMovementComponent = nullptr;
In Tank.h file and Compiled It in UE

38800237_1818468334867806_3932514460429713408_n

My Projectile Blueprint value is changed to “None” Automatically by Engine
It make a Crash Error when I started a game play(Push Play Button in UE)

38849793_1818471804867459_2874960793370099712_n

My Question is :
Why does The Engine Change my Projectile Blueprint value to “None” ? and
How to solution to prevent this problem?

Thank you.

1 Like

I’m also having this issue, it’s super annoying. Anybody know how to fix it? I’m on 4.20.

What version are you using?

Hi doogog
You should be careful about various bugs in v.4.20
I got some Message from Sam, Follow This

sam

Hi Sattawat,

Seems like 4.19 is having this same issue I believe. It looks like it’s been around since 4.12?

I downgraded to 4.18 and have the same issue… basically every time I make a change to the Tank.h, the UPROPERTIES are reset to their defaults, which for the ProjectileBlueprint is nullptr…

It does give you a salient reminder to protect your pointers! I have a habit of including

UE_LOG(LogTemp, Error, TEXT("Projectileblueprint must be set")) 

in my pointer protection code… (or whatever thing is not set). Saves me a LOT of debugging time.

Hi Everyone
I just pass through on section 5 lecture 285 “Animation Notify Events” and I have seen the same issue again on my Blueprint

When I set some variable or function in .h file that can appear in Blueprint in my case I just add
UFUNCTION(Blueprintcallable, Category = “Input”) over my function

and then some value in Blueprint is reset to default value (none)
But I have some debug on my code already.

I think for every Pointer variable on C++ code must be check a NULL Pointer for every time before to use that variable (to prevent the engine crash) and maybe add UE_LOG to guide you What the issue happen?

(I use 4.19)

Unfortunately this bug is still present in 4.21.1. I updated related threads on the forums and AnswerHub:

I doubt it will get fixed any time soon since Epic seems to think it’s no longer an issue:
https://issues.unrealengine.com/issue/UE-51994

I might try to find a workaround unless someone has already done so (please share if you have).

[Update]
I found a simple workaround if anybody is curious - the solution was simply to make ProjectileBlueprint a property that could be set in Tank_BP’s event graph:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Setup")
TSubclassOf<AProjectile> ProjectileBlueprint;

Hope that helps anyone who was as annoyed as I was that I had to keep setting the default value every time I opened the editor or Hot Reloaded!

3 Likes

After endless frustration with blueprint properties resetting and getting the dreaded nullptr, I seem to ahve found a fix. I deleted all generated files and rebuilt my project from scratch. Everything has been working flawlessly for the last couple days. Specifically, I deleted

.vs
Binaries
Intermediate
Saved
*.sln

Then right-click the .uproject and select “Generate Visual Studio project files”. Then open the project and recompile and redo lighting. When first opening Visual Studio, it will also rebuild its own database stuff. After it’s all done, things just worked for me. Yay!

I’m using the latest Unreal editor (as of this writing), version 4.21.2.

1 Like

Pyro-GX’s solution works very well.

For all the new devs like me that can’t figure out how to get the purple SET block, here’s the recipe:

The UPROPERTY lines must be in the protected or public sections. “BlueprintReadWrite” is not allowed in the private section. You can leave the edit level at “EditDefaultsOnly” as per Ben’s recommendation.

After compiling everything successfully, go to your Tank_BP’s Event Graph. Pull a “Tank Aiming” component from the Components list and drop it in the graph as in Gyro-GX’s image above. Now for the magic. Left click and drag from the Tank Aiming connector and let go to see the popup menu. Either search for “Set Projectile Blueprint” and click it or scroll all the way down to the bottom. Open “Variables” then open “Setup”. Ta-da! There’s the purple “Set Projectile Blueprint”! Click on it to add it to the event graph. Choose “Projectile_BP” from the drop down then wire it into the execute path as above. Now you can save the Tank_BP and compile.

2 Likes

Privacy & Terms