Something about UPROPERTY()

In this course, we add a member variable into the UTankAimingComponent:

private:
    UStaticMeshComponent* Barrel;

Is it better to write like this?

private:
    UPROPERTY()
    UStaticMeshComponent* Barrel;

For pointers? Definitely, cause then they don’t get Garbage Collected by accident. You’ll also need to do that for variables that you want saved when you start implementing save games (which is something not covered in the course)

1 Like

Wait, does that mean I need to make every variable that I want to make saveable a UPROPERTY()? And if I got your explanation right almost every pointer then needs to be a UPROPERTY()

Privacy & Terms