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:
UPROPERTY(EditAnywhere)
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
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 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
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
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.