UPROPERTY does nothing

Hi everyone, i just started using Unreal Engine, and i’m stuck on something very stupid, though nowhere and no one was able to help me…
So, i just created an Actor, and i’m moving him forward with a certain speed.
This speed is just a simple float variable, nothing more, and all works fine.
But if, instead of:

float m_speed;

i do:

float m_speed;

The actor stops moving…the same effect as if i set the variable to 0, or not set it at all.

I tried EVERYTHING, i tried to give it a value both in the declaration and in the contructor, i tried to make it an int, i tried playing around with the UPROPERTY macro options, nothing, and i’ve seen UE tutorials and pieces of code online, which are identical to mine…

I will not post the code of my cpp file, just because it’s really basic and i copied it from a UE tutorial, and it is working (if i use a normal variable), so it is not the problem

UPROPERTY has lots of functionality

you’ll use it mainly to communicate with the engine

will make the variable available in the engine to edit it
it should not change the value on its own or lock it at 0

I can’t tell what’s wrong but it’s surely not from UPROPERTY

The only thing i changed was passing from a float, to a uproperty float, what else could it be?

UPROPERTY(EditAnywhere) it’s litterally the only line i added to the code, it seems strange that the problem is not there

Is your actor this straight class or do you have a blueprint based off this C++ class?

That’s the only way I can think that UPROPERTY would break it. UPROPERTY just exposes the variable to the engine for blueprints, replication, etc. What im saying is if you have a blueprint for your actor, based off your Class, then m_speed is now available for edit there as well. Make sure the blueprint hasn’t set that to any unintended value.

I don’t have a blueprint…i just created the actor, dragged it on screen and added a mesh to it…nothing else…

I managed to log the variable on the console, it is actually changing value, but the object does not move…
Here’s the code, maybe you see something i don’t…running_time is the property

Super::Tick( DeltaTime );

UE_LOG(LogTemp, Warning, TEXT("Time %f"),running_time);
FVector NewLocation = GetActorLocation();
float DeltaHeight = (FMath::Sin(running_time + DeltaTime) - FMath::Sin(running_time));
NewLocation.Z += DeltaHeight * 50.0f;       //Scale our height by a factor of 20
running_time += DeltaTime;

Are you sure you have the RootComponent specified ?

Are you using a blueprint?
Try deleting and recreating it. There’s a good change it didn’t have a value and, when you made it aware of the m_speed float, it zeroed the value.
You can also search for the value of m_float there :wink:

You have set the default value in code to right?

EditAnywhere means it’s editable on instances as well as in the default panel. If you’ve already placed the actor in the level, it won’t update that property from the Blueprint in the Content Browser or from the code file, you’ll have to re-place it to do that, and recreate it in the CB too probably.

EditDefaultsOnly is probably a better choice if you don’t want to be able to change that float on an instance-by-instance basis. I’d also give it a category too.

I actually just added a float member to scale input and verified this works correctly,

As TheJamsh pointed out, you probably want the field to only be editable on an actual instance so the change is serialized out properly.