I am programming my custom class derived from pawn and I ran into issue that UPROPERTY simply doesn’t show variables in Blueprint editor. I tried to reload/recompile project and I also tried different property specifiers but none of them worked.
Any ideas what may cause the problem?
Class header:
UCLASS()
class TX_API AMainChar : public APawn
{
GENERATED_BODY()
public:
// Sets default values for this pawn's properties
AMainChar();
float velocity = 0;
S_SERIALIZABLE float maxRunVelocity;
S_SERIALIZABLE float maxWalkVelocity;
S_SERIALIZABLE float acceleration;
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
S_FUNCTION void Move();
S_FUNCTION void ReduceToWalk(FVector dir);
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
void Accelerate(bool decelerate = false);
};
Class implementation
// Fill out your copyright notice in the Description page of Project Settings.
#include "MainChar.h"
// Sets default values
AMainChar::AMainChar()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
/*maxRunVelocity = 600;
maxWalkVelocity = 100;
acceleration = 50;*/
}
// Called every frame
void AMainChar::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void AMainChar::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
void AMainChar::Move()
{
FVector dir = FVector::ForwardVector;
Accelerate();
dir = dir * velocity;
APawn::AddMovementInput(dir);
}
// Called when the game starts or when spawned
void AMainChar::BeginPlay()
{
Super::BeginPlay();
}
void AMainChar::Accelerate(bool decelerate)
{
float factor = 1;
if (decelerate)
factor *= -1;
velocity += acceleration * factor;
if (velocity > maxRunVelocity)
velocity = maxRunVelocity;
}