PawnTurret not executed

This is driving me crazy.
For some reason the PawnTank.cpp is executed, while PawnTurret.cpp is not.
There should be a silly error that I don’t see.

PawnTank.h

#pragma once

#include "CoreMinimal.h"
#include "PawnBase.h"
#include "PawnTank.generated.h"

class USpringArmComponent;
class UCameraComponent;

UCLASS()
class TOONTANKS_API APawnTank : public APawnBase
{
	GENERATED_BODY()

private:
	UPROPERTY(VisibleAnyWhere, BlueprintReadOnly, Category="Components", meta=(AllowPrivateAccess="true"))
	USpringArmComponent* SpringArm;
	UPROPERTY(VisibleAnyWhere, BlueprintReadOnly, Category="Components", meta=(AllowPrivateAccess="true"))
	UCameraComponent* Camera;

	UPROPERTY(VisibleAnyWhere, BlueprintReadOnly, Category="Move Data", meta=(AllowPrivateAccess="true"))
	FVector MoveDirection;
	UPROPERTY(VisibleAnyWhere, BlueprintReadOnly, Category="Move Data", meta=(AllowPrivateAccess="true"))
	FQuat RotationDirection;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Move Data", meta=(AllowPrivateAccess="true"))
	float MoveSpeed = 100.f;
	UPROPERTY(EditanyWhere, BlueprintReadOnly, Category="Move Data", meta=(AllowPrivateAccess="true"))
	float RotateSpeed = 100.f;

	void CalculateMoveInput(float value);
	void CalculateRotateInput(float value);

	void Move();
	void Rotate();


public:
	APawnTank(); //Costruttore della classe

		// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
};

PawnTank.cpp ==> No problem here. UE_LOG is shown.

#include "PawnTank.h"
#include "GameFramework/SpringArmComponent.h"
#include "Camera/CameraComponent.h"

// Creo il constructor
APawnTank::APawnTank()
{
	SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Spring Arm"));
	SpringArm->SetupAttachment(RootComponent); //Il Root Component il il capsule collider
	Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera component"));
	Camera->SetupAttachment(SpringArm);
}

// Called when the game starts or when spawned
void APawnTank::BeginPlay()
{
	Super::BeginPlay();
	UE_LOG(LogTemp, Warning, TEXT("I am in Begin Play - PawnTank"));
}

// Called every frame
void APawnTank::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
    Rotate();
    Move();
}

// Called to bind functionality to input. Creato con la classe Pawn
void APawnTank::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);
    PlayerInputComponent->BindAxis("MoveForward", this, &APawnTank::CalculateMoveInput);
    PlayerInputComponent->BindAxis("Turn", this, &APawnTank::CalculateRotateInput);
}

void APawnTank::CalculateMoveInput(float Value)
{
   MoveDirection = FVector (Value * MoveSpeed * GetWorld()->DeltaTimeSeconds, 0, 0);
}

void APawnTank::CalculateRotateInput(float Value)
{
    float RotateAmount = Value * RotateSpeed * GetWorld()->DeltaTimeSeconds;
    FRotator Rotation = FRotator(0,RotateAmount,0);
    RotationDirection = FQuat(Rotation);
}

void APawnTank::Move()
{
    AddActorLocalOffset(MoveDirection, true);
}

void APawnTank::Rotate()
{
    AddActorLocalRotation(RotationDirection, true);
}

PawnTurret.h

#pragma once

#include "CoreMinimal.h"
#include "PawnBase.h"
#include "PawnTurret.generated.h"

UCLASS()
class TOONTANKS_API APawnTurret : public APawnBase
{
	GENERATED_BODY()

private:
	// Called every frame
	virtual void Tick(float DeltaTime) override;

public:

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

};

PawnTurret.cpp ==> UE_LOG is not shown. Seems that BeginPlay in PawnTurret.cpp is not executed

#include "PawnTurret.h"

// Called when the game starts or when spawned
void APawnTurret::BeginPlay()
{
	Super::BeginPlay();
	UE_LOG(LogTemp, Warning, TEXT("I am in Begin Play - PawnTurret"));
}

// Called every frame
void APawnTurret::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

I’ve got the problem.
I forgot to drag the class PawnTurret into the level.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms