I got this problem in my code. I try to make a pointer to a float so i can add the reference to in the editor.
UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class MYPART_API UMyActorComponent : public UActorComponent
{
//...
public:
//The direction of the character
UPROPERTY(EditAnywhere)
float * direction = nullptr;
//Player to follow
UPROPERTY(EditAnywhere)
AActor * player = nullptr;
};
All the header code:
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "MyActorComponent.generated.h"
UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class MYPART_API UMyActorComponent : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UMyActorComponent();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
public:
//The direction of the character
UPROPERTY(EditAnywhere)
float * direction = nullptr;
//Player to follow
UPROPERTY(EditAnywhere)
AActor * player = nullptr;
};
Comes with the error:
Inappropriate ‘*’ on variable of type
‘float’, cannot have an exposed
pointer to this type.
I just want a simple float pointer… why?!
Has it something to do with how UPROPERTY works?