UE documentation, how do I understand it?

I was looking for a way to get the distance between two FVectors in C++ so I looked it up on the UE documention. I looked at the FVector math part and went down to functions. Some of these functions had no discription! I used the vector math include and tryed to use some of the different fuctions. For exaple I tryed PointsAreNear and it says that points are near is undefined. Also what does it mean by a static or constant function. I’m almost sure I am using this wrong but the documentation shows the syntax and it looks right to me.



image
How do I understand this confusing documentation? I have used it for otherthings before and got things right. But so many times its unclear with no explanation.

You can find the distance between 2 vectors like so:
(V1 - V2).Size()

Your issues don’t really have much to do with the Unreal documentation. They are all related to C++ syntax.

static member functions are part of the class but aren’t called on objects of that class.

struct Exmample
{
    static int AddFive(int Value)
    {
        return Value + 5;
    }
}

void Foo()
{
    // Test == 8
    int Test = Example::AddFive(3);
}

With PointsAreNear you would write

FVector Point1(100.);
FVector Point2(50.);

if (FVector::PointsAreNear(Point1, Point2, 1.f))

You don’t say float 1.f because you’re not declaring a variable, it expects a value of that type which 1.f is.
You also need to initialise your vectors as the default constructor does no initialisation and that function would attempt read the values of those uninitialised variables which will be bad.

Speaking of static functions, FVector also has a static Dist function that takes 2 vectors as arguments. The earlier form I posted works fine but you can also use FVector::Dist(V1, V2).

Thank you, I will look more into the C++ syntax.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.