UPROPERTY(EditAnywhere) variable when changed in the editor dont reflect in the game

So I have created Zoom ability to my pawn and I would like to be able to change the Maximum and Minumum zoom in the editor
So I created this in the .h file:



        UPROPERTY(EditAnywhere, Category = Ball)
	float MinZoom;

	UPROPERTY(EditAnywhere, Category = Ball)
	float MaxZoom;


declared them in the constructor
and made created a method for zooming ability in .cpp:



void AMyPawn::Zoom(float Axis)
{
	float ArmLengthfactor = -Axis * 20.f;
	CameraSpring->TargetArmLength = FMath::Clamp(CameraSpring->TargetArmLength + ArmLengthfactor, MinZoom, MaxZoom);
}


which worked!
but I decided to tweak the values in the editor to get a more feasible value, but for some reason when I changed the value in editor nothing changed in zooming.
So I went in the code changed it manually and then it worked.

Why is it that when I change the value in the editor doesnt work but when I change the value in code it works?

It probably is working but you’re not creating an instance of the Blueprint you created.

Make sure the pawn you’re spawning is the Blueprint, not the C++ class.

Nope, I was doing exactly what you said, Im spawning the blueprint not the c++ class. Its not working

Hmm, definitely sounds like human error this one. Try dropping in a breakpoint to see the actual value it’s using.

hmmm Ok VERY, VERY strange I have deleted the instance on the level and placed it again from the content browser, and not it works?!

Ah, it’s possible sometimes for serialized data to not be properly updated on blueprint instances that are already placed somewhere or created. In fact in my experience, BP’s tend to store a lot of redundant data when you change your classes.

You can test this theory by:

  1. Adding a uproperty, and setting it to a non-default value in a Blueprint.
  2. Save the Blueprint
  3. Remove the UPROPERTY from c++, open the blueprint, recompile and saved.
  4. Add the property back in C++. If you open the blueprint, the old value you entered is somehow still saved.