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

57_bt_urc
unreal-cpp

#1

Hello Everyone

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

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)

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

Thank you.


#2

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?


#3

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

sam


#4

Hi Sattawat,

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


#5

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.


#6

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)


#7

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!


#8

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.