Rotation Problem that is fixed by adding specific LOG?!

I have a problem with the turret rotation when i turning to the left side of the tank the turret is acting as expected but when i turning the view to the right side of the tank the turret is aiming to the opposite side - its like it is rotating only on the left side of the tank.

i pleased logs each time in a different place and used the trace to make sure the calculation of the target is correct - everything was as expected.

when i added a specific log before the MoveBarrelTowards call (in the tankAimingComponent.cpp) the turret started to turn as expected for both sides.

i had different logs at that place but for some reason only that specific log is fixing the issue
(i am working with UE 4.22)

any idea what might be the problem?

if (bHaveAimSolution)
{
	auto AimDirection = OutLaunchVelocity.GetSafeNormal();
	auto Time = GetWorld()->GetTimeSeconds();
	auto OurTankName = GetOwner()->GetName();
	UE_LOG(LogTemp, Warning, TEXT("Out Launch Velocity before Normal: %s after Normal: %s"), *OutLaunchVelocity.ToString(), *AimDirection.ToString());
	//UE_LOG(LogTemp, Warning, TEXT("Out Launch Velocity before Normal: %s"), *OutLaunchVelocity.ToString());
	//UE_LOG(LogTemp, Warning, TEXT("%f: %s, Aiming solution found %s"), Time, *OurTankName ,*AimDirection.ToString());
	MoveBarrelTowards(AimDirection);
	
else {
	//if no solution found do nothing
	auto Time = GetWorld()->GetTimeSeconds();

The same thing is happening to me. See my question (and video of problem) here: Turret behaving strangely

Your post gave me an idea to use OutLaunchVelocity as the parameter for MoveBarrelTowards() function, because I think the .GetSafeNormal() is returning bizarre values so I went ahead and interestingly it works. Try it for yourself. It must be a bug with newer versions of Unreal, because I’m using 4.23.

i rewrite the GetSafeNormal function on my local class replacing the invSqrt with the following code and it worked
the bug seems to be with the invSqrt.

const float Scale = FMath::Sqrt(SquareSum);
//UE_LOG(LogTemp, Warning, TEXT(“Scale: %f”), Scale);
return FVector(Vector.X / Scale, Vector.Y / Scale, Vector.Z / Scale);

It’s a bug with MSVC 16.3. It’s fixed in 16.4 (not out yet, only in Preview).

Privacy & Terms