Same pointer is valid in BP but null in C++

Arty McLabin
Sun, 29 Apr 2018 19:12:18 +0000
Blueprint

The next uproperty component pointer:

UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
USkeletalMeshComponent* mesh;

constructor code:

mesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("mesh")); //succeeds all the time. checked.

Is returning a valid value in BP but null in C++.

Even calling a wrapper C++ ufunction brings the same effect:

UFUNCTION(BlueprintCallable, BlueprintPure)
UMeshComponent* getMesh(){return mesh;}

When called in C++ it’s nullptr, but is valid in BP. The mesh exists and is seen in the world.

Important:
What is even more strange - is the fact that this behaviour occurs randomly with around 10% chance every play in PIE (without recompiling), while other 90% plays are completely fine both in BP and C++.
20 posts - 1 participant