Rotation around the Pitch axis is bugged?

Hi, I am making a simple Pickup actor and on the Tick function I want to rotate it with the FRotator(15, 30, 45) each second. I encountered a strange bug (The rotation around the Pitch axis locks after 90deg). I wan’t to do this via C++ so please don’t answer with blueprints.

Here is the code if it might help:

// Pickup.h

UCLASS()
class APickup : public AActor
{
	GENERATED_UCLASS_BODY()

public:
	/** The root component of the pickup object */
	UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = "Components")
	TSubobjectPtr<USceneComponent> SceneComponent;

	/** The static mesh of the pickup object */
	UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = "Components")
	TSubobjectPtr<UStaticMeshComponent> PickupMesh;

	/** The rotation rate of the pickup object in degrees/second for each axis of the FRotator */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Rotation")
	FRotator RotationRate;

	virtual void Tick(float DeltaTime) override;
};


// Pickup.cpp

APickup::APickup(const FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	this->PrimaryActorTick.bCanEverTick = true;

	this->SceneComponent = PCIP.CreateDefaultSubobject<USceneComponent>(this, TEXT("SceneComponent"));
	this->RootComponent = this->SceneComponent;

	this->PickupMesh = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("PickupMesh"));
	this->PickupMesh->AttachTo(this->RootComponent);

	this->RotationRate = FRotator(15.0f, 30.0f, 45.0f);
}

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

	this->SetActorRotation(this->GetActorRotation() + (this->RotationRate * DeltaTime));
}

I would try changing your code to match my answer to your similar question here and see if that fixes both problems for you.

Yeap, it is actually the same code. Thanks again mate. Works perfectly :slight_smile:

Awesome. Glad it worked!

If you possess a Pawn and try to rotate it in any direction, you’ll be limited to 90% in any direction. It’s a bug acknowledged by Unreal developers.

If you are using blueprint, you can do the rotation in your custom PlayerController blueprint and freely rotate 360 degrees without limit. The rotation values (roll, yaw, pitch) can even exceed 360 degrees and it’ll work perfectly. So rotate the actor from within your PlayerController blueprint instead of your individual Pawn blueprint.