FTransform cannot edit

UPROPERTY(EditAnywhere, BlueprintReadWrite)
FTransform MyTransform = FTransform(FRotator::ZeroRotator, FVector::ZeroVector);

As variable of a SceneComponent, when this is edited in the actor BP editor where the component is added, the value always comes back to the default value on runtime. It only happens with the FTransform, other types such as FVector works fine.

I’m slightly shocked that statement compiles given that you are doing an assignment operation in the class declaration.

Try this instead:

 UPROPERTY(EditAnywhere, BlueprintReadWrite)
 FTransform MyTransform;

Since you want this variable to be editable and such, you don’t need to assign it manually (Unreal will handle the serialization for you).

I’ve written many classes and I’ve been setting the default value in the header file, and all of them worked fine. I’ve thought of setting them in the constructor but it’s easier to them in the header file.

Anyways, I actually have tried that but it’s the same. I just put a zero value so that what I meant by back to default would be clear

Ah, that’s a C++ 11 thing. Interesting.

Unfortunately there isn’t much “magic” that can cause a property not to be editable. Everything seems okay (without seeing the rest of the header file).

I’d check to see if UHT is complaining about anything. You could also try to clean your solution so it regenerates all the boilerplate code.

The only thing in the header file is the FTransform, I tested it in a clean project, so it would be easy to recreate.

The class inherits from SceneComponent.

The property is editable in the BP editor, but the value goes back to the default on runtime. But the variable can still be edited during runtime

Hey Kurosu143-

Does the same behavior occur in a new, empty project as well? I copied the code you provided into a SceneComponent class and when I set the value in a blueprint that used my scene component, the set value was printed at runtime. I was also able to set individual instances of my blueprint’s variable in the viewport.

If possible, please provide the reproduction steps to allow me to create a test project that matches your setup or a small sample project showing the issue.

Hey Kurosu143-

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will follow up.

Cheers

I found the problem, it’s because Editable variables of object already placed in the editor will not be updated when you edit the BP variable. Which is fine I guess.