Download

property value is always null, even if object was assigned in blueprint

hi,

so i just started converting my blueprints to c and i have a UActorComponent class that i want to have a UCurveFloat variable/property that can be set via the objects details panel. however, the curve is always null.

i get to select the curve in the editor but when i move the object (the owner actor calls the initialize function) i get the curve is null output

thanks for the help

here is the header



#pragma once

#include "CoreMinimal.h"
#include "VIZCMeshSpline.generated.h"

class UCurveFloat;

UCLASS(config = Engine, Blueprintable, BlueprintType, ClassGroup = (Custom), meta = (BlueprintSpawnableComponent, IsBlueprintBase = true))
class V3_API UVIZCMeshSpline : public UActorComponent
{
    GENERATED_BODY()

  public:
    UVIZCMeshSpline();

    UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = "Way Curve", Category = "Default", MultiLine = "true", OverrideNativeName = "WayCurve"))
    UCurveFloat* WayCurve;

    virtual void Initialize(float TimeStart) override;
};


and the source



#include "VIZCMeshSpline.h"

#ifdef _MSC_VER
#pragma warning (push)
#pragma warning (disable : 4883)
#endif
PRAGMA_DISABLE_DEPRECATION_WARNINGS
PRAGMA_DISABLE_OPTIMIZATION
UVIZCMeshSpline::UVIZCMeshSpline() : UActorComponent()
{
  bCanEverAffectNavigation = false;
}

PRAGMA_ENABLE_OPTIMIZATION
void UVIZCMeshSpline::Initialize(float TimeStart)
{
  if (!IsValid(WayCurve))
  {
    UE_LOG(LogTemp, Warning, TEXT("UVIZCMeshSpline curve is null"));
    return;
  }
}


I’m not positive, but one possible issue here is that sometimes Unreal is a little confusing in terms of what happens when when a game is starting up. For example, even though you have set the WayCurve variable in the Blueprint class’ Details panel, I’m not sure whether the engine looks at that before the Initialize function gets called in C++. Or perhaps it takes a moment to load the WayCurve and your Initialize function is getting called before the curve finishes loading. Perhaps to test it, go into your blueprint PlayerController class and create a function that is bound to some key on the keyboard that tests whether some actor with that component has a valid WayCurve and the returns true if it does or false if it doesn’t. Then you can run that in PIE and click the key after a couple seconds to see whether the WayCurve is valid after everything has had a chance to load. If so, the problem lies in when you are calling the Initialize function.

it did disappear after a day or so. so i guess it was fine to begin with but the build was somehow bad !?

however, the posted code should work fine