Why did not we write GetSafeNormal when using DotProduct?

TankMovementComponent.Cpp

auto TankForward = GetOwner()->GetActorForwardVector();
auto AIForwardIntention = MoveVelocity.GetSafeNormal();
auto ForwardThrow = FVector::DotProduct(TankForward, AIForwardIntention);

TankTrack.Cpp

auto SlippageSpeed = FVector::DotProduct(GetRightVector(), GetComponentVelocity());

Why did we use GetSafeNormal with MoveVeolcity in DotProduct at first code (TankMovementComponent) shown above and did not do that with GetComponentVelocity at (TankTrack) ?

What are the cases that should we use GetSafeNormal() ?

1 Like

GetSafeNormal gets a normalised copy of the vector (if it’s safe to do so). A normalised vector means a vector of length 1, i.e. no magnitude just the direction

We don’t do that for GetComponentVelocity because we’re interested in both the vectors direction and magnitude.

Mr @DanM
I’m sorry for my questions that may seem simple and stupid but really i have problems to understanding the techniques of Vectors and how they work, so I hope you bear some of these questions :slight_smile:

We don’t do that for GetComponentVelocity because we’re interested in both the vectors direction and magnitude.

If we used GetComponentVelocity to get both direction and magnitude, Why did we use GetRightVector() at the same line of code that i think that is another direction?
In other words DotProduct must have two parameters, So Are the first one must be direction?

auto AIForwardIntention = MoveVelocity.GetSafeNormal();

What is the MoveVelocity ?

Yes, GetRightVector is another vector that’s just a direction, unsurprisingly the direction going right.

Not specifically no. It’s just what Ben wants here.

It’s the velocity the tank wants to move in.

1 Like

Privacy & Terms