Hey,
I’m trying to normalize the MoveVelocity just as in the video, but logging the vector to the console shows that it hasn’t been normalized at all. I tried it with and without providing a float parameter in GetSafeNormal() and I also tried GetUnsafeNormal(). Using UE 4.23.0.
It’s really confusing me because it seems such a simple thing… Any help much appreciated!
Screenshot of the map (player selected) and console output:
TankNavMovementComponent.cpp:
#include "TankNavMovementComponent.h"
#include "TankTrack.h"
#pragma region Overrides
void UTankNavMovementComponent::RequestDirectMove(const FVector& MoveVelocity, bool bForceMaxSpeed)
{
// No need to call Super. Logic will be replaced.
const FVector TankForwardVectorNormal = GetOwner()->GetActorForwardVector();
// BUG: Why doesn't this get normalized?
const auto MoveVelocityNormal = MoveVelocity.GetSafeNormal(0.0001f);
const float ForwardThrow = FVector::DotProduct(TankForwardVectorNormal, MoveVelocityNormal);
UE_LOG(LogTemp, Warning, TEXT("[%s] MoveVelocity: %s"), *GetOwner()->GetName(), *MoveVelocity.ToString());
UE_LOG(LogTemp, Warning, TEXT("[%s] TankForwardVectorNormal: %s, MoveVelocityNormal: %s, ForwardThrow: %f"),
*GetOwner()->GetName(),
*TankForwardVectorNormal.ToString(),
*MoveVelocityNormal.ToString(),
ForwardThrow);
IntendMoveForward(ForwardThrow);
}
#pragma endregion