When I modify the C++ code, I always need to re modify the variables in the blueprint

I set some variables in the C++ code, like this :
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ShootState)
float MaxBullet;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = ShootState)
	float CurrentBullet;

And I call them by reference in the blueprint.
If I change the c++ code, I must change the variables in the blueprint.
I want to know why.


When you change the variable in C++, the whole class gets recompiled. It is now different from the class in the last compile, therefore the editor replaces the old class with the new one. This may break your Blueprint, since all the references are made to the old class. It tries to convert all the references to the new class, but that may not always work: If you for example changed the name of the variable the Blueprint node suddenly points to a variable that is not existent anymore (because it has a different name now). Thats when you have to fix it manually. Basically your “Character Ref” node returns a different type, that may not have a “Current Bullet”. If the Blueprint detects that, you get a Blueprint Compile error.

Thank your.