Tick Function - BUG

Hi people.

My Code:

.cpp

#include "TheUniverse.h"
#include "MainGamePlayerPawn.h"


// Sets default values
AMainGamePlayerPawn::AMainGamePlayerPawn()
{
	PrimaryActorTick.bCanEverTick = true;

	//Set variable
	angle.Yaw = -90;
}

AMainGamePlayerPawn::~AMainGamePlayerPawn()
{

}


//Main Function

void AMainGamePlayerPawn::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);


		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, angle.ToString());
		//Apply Rotation
		if (active == true && direction == false)
		{
			GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Right"));
			angle.Yaw = angle.Yaw - 1;
		}
		else if (active == true && direction == true)
		{
			GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Left"));
			angle.Yaw = angle.Yaw + 1;
		}
		else
		{
			GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Nothing"));
		}


		this->SetActorRotation(angle);

}

.h

#pragma once

#include "GameFramework/Pawn.h"
#include "MainGamePlayerPawn.generated.h"

UCLASS()
class THEUNIVERSE_API AMainGamePlayerPawn : public APawn
{
	GENERATED_BODY()

public:
	// Sets default values for this pawn's properties
	AMainGamePlayerPawn();
	~AMainGamePlayerPawn();

	//Main Function
	virtual void Tick(float DeltaTime) override;

	// Camera settings
public:
	//Rotation
	void Rotate(bool Direction, bool Active);


protected:
	UPROPERTY(BlueprintReadWrite, category = "CameraPos")
		FRotator angle;

	UPROPERTY(BlueprintReadWrite, category = "CameraPos")
		int32 zoom = 0;

	UPROPERTY(BlueprintReadWrite, category = "CameraPos")
		int32 lateralPos = 0;

	bool direction, active = false;
 
};

In the Tick function:

-The first if: is when the player press E (To rotate to the right).

-The second: is when the player press Q (To rotate to the left).

-And the else is when the player press no key.

But When I launch the game, I have this Debug Message (for this example I press Q (Left)):

Nothing ← Wrong State

P= 0.000000 Y=-90.00000 R=0.000000 ← Wrong Rotation

Left ← Correct State

P= 0.000000 Y=-89.00000 R=0.000000 ← Correct Rotation

Nothing ← Wrong State

P= 0.000000 Y=-90.00000 R=0.000000 ← Wrong Rotation

Left ← Correct State

P= 0.000000 Y=-88.00000 R=0.000000 ← Correct Rotation

Nothing ← Wrong State

P= 0.000000 Y=-90.00000 R=0.000000 ← Wrong Rotation

Left ← Correct State

P= 0.000000 Y=-87.00000 R=0.000000 ← Correct Rotation

Nothing ← Wrong State

P= 0.000000 Y=-90.00000 R=0.000000 ← Wrong Rotation

Left ← Correct State

P= 0.000000 Y=-86.00000 R=0.000000 ← Correct Rotation

Nothing ← Wrong State

P= 0.000000 Y=-90.00000 R=0.000000 ← Wrong Rotation

Left ← Correct State

P= 0.000000 Y=-85.00000 R=0.000000 ← Correct Rotation

And the pawn doesn’t rotate.

Can you help me ?

I don’t know how you set your “active” and “direction” variables, but from your posted source code and the output I would strongly assume that there are two actors. The first doesn’t receive input and doesn’t rotate (the lines with “nothing”) and the second one behaves correctly (the lines with “Left”). And you only seem to see the first incorrect pawn. Perhaps you take a look in how they are created? E.g. is there one of this pawns created by default by your game mode, in addition to a manually created one?

It works thanks