First, in 4.11+, GENERATED_BODY()
should be used instead of GENERATED_USTRUCT_BODY()
:
At least as of version 4.11, using
GENERATED_USTRUCT_BODY() will result
in a UHT error stating
GENERATED_BODY() is expected.
https://wiki.unrealengine.com/Structs,_USTRUCTS(),_They’re_Awesome
Another problem is that you mark methods FPlayerLocation()
, FPlayerRotator()
with UPROPERTY
:
UPROPERTY(BlueprintReadOnly)
FVector FPlayerLocation();
So, please change it to a property (from method, as above) and keep it marked with UPROPERTY:
UPROPERTY(BlueprintReadOnly)
FVector PlayerLocation;
Alternatively, if you want a method, you can expose it with UFUNCTION:
UFUNCTION(BlueprintCallable)
FVector GetPlayerLocation() const {
return this->PlayerLocation;
}
private:
FVector PlayerLocation;
Finally, if you want to access your USTRUCT from blueprints, add:
USTRUCT(BlueprintType)
So, after those changes, your code should be like this:
USTRUCT(BlueprintType)
struct FLocationStruct
{
GENERATED_BODY()
FLoctationStruct();
UPROPERTY(BlueprintReadOnly)
FVector PlayerLocation;
UPROPERTY(BlueprintReadOnly)
FRotator PlayerRotator;
};
It is also worth noting, that if you want a struct that contains location and rotation (and scale), FTransform does exactly that.