Kochab
(Kochab)
May 26, 2014, 4:47pm
1
Right now I’m doing this:
float vectorLength = FMath::Sqrt(FMath::Pow(someVector.X, 2) + FMath::Pow(someVector.Y, 2) + FMath::Pow(someVector.Z, 2));
I did find FVector::ToDirectionAndLength
, but I must have been using it wrong cause the game would crash. All I needed was the length anyway.
Chris528
(Chris528)
May 26, 2014, 5:46pm
2
Did you think to check out the header file for FVector?
FORCEINLINE float FVector::Size() const
{
return FMath::Sqrt( X*X + Y*Y + Z*Z );
}
float vectorLength = someVector.Size();
Kochab
(Kochab)
May 26, 2014, 6:18pm
3
Ah, I was looking for length, not size. Thanks.
This must be a really common misconception. Even the documentation clarifies that size
is actually length/magnitude
and also says that the Size()
returns the length of the vector (not the “size”). :c
Just InCase if anyone is searching for getting the magnitude of the character velocity
if (GetCharacterMovement()->Velocity.Size() == 0)
{
//Character not moving or some bool to store the info
}
To check if your character is moving or not !!
2 Likes