PRotator goes to 90 degrees or 0 degrees, but not in between

Hi. I’m using Unreal 4.20 and this is my output log:
sniip

and this is my code:

    #include "Kismet/GameplayStatics.h"
    #include "TankAimingComponent.h"
    
    
    // Sets default values for this component's properties
    UTankAimingComponent::UTankAimingComponent()
    {
    	PrimaryComponentTick.bCanEverTick = true;
    
    	// ...
    }
    
    
    // Called when the game starts
    void UTankAimingComponent::BeginPlay()
    {
    	Super::BeginPlay();
    
    	// ...
    
    }
    
    
    // Called every frame
    void UTankAimingComponent::TickComponent(float DeltaTime, ELevelTick TickType, 
    FActorComponentTickFunction* ThisTickFunction)
    {
    	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
    
    
    }
    
    void UTankAimingComponent::AimAt(FVector TargetLocation, float LaunchSpeed) {
    
    	if (!Barrel) { return; }
    	FVector TossVelocity;
    
    	bool bHaveAimSolution = UGameplayStatics::SuggestProjectileVelocity
    	(
    		this,
    		TossVelocity,
    		Barrel->GetSocketLocation(FName("Projectile")),
    		TargetLocation,
    		LaunchSpeed,
    		ESuggestProjVelocityTraceOption::DoNotTrace
    	);
    
    		if (bHaveAimSolution) {
    			auto AimDirection = TossVelocity.GetSafeNormal();
    			MoveBarrel(AimDirection);
    		}
    
    }
    
    void UTankAimingComponent::MoveBarrel(FVector AimDirection) {
    
    	auto BarrelRotator = Barrel->GetForwardVector().Rotation();
    	auto AimAsRotator = AimDirection.Rotation();
    	UE_LOG(LogTemp, Log, TEXT("AimAsRotator %s"), *AimAsRotator.ToString());
    
    }
    
    void UTankAimingComponent::SetBarrelReference(UStaticMeshComponent* BarrelToSet) {
    
    	Barrel = BarrelToSet;
    
    }

Privacy & Terms