I have a shedload of X, Y character location coordinates that I need to calculate a single distance figure from a specific location (also an X,Y coordinate).

Can i ask what is the calculation to do this, I need to do these in an excel spreadsheet so need the calculation rather than the BP.

You can use the distance blueprint node, one is for vector3 (x,y,z) and one is the same but for two actors.

If you want to manually do it it would be the vector length (another blueprint node) of one vector subtracted by the other.

If you wanted to further manually do it it would be: (source: https://stackoverflow.com/questions/…een-two-pointshttps://stackoverflow.com/questions/…points/5230380) I recommend stackoverflow as a place to find alot of answers to common formulas used in games, with the added benefit of many examples being broken down to not take into account specific APIs that make things easier (so you can learn what the blueprint function nodes are actually doing behind the scenes and make it yourself if need be for a different purpose). You can even look at questions answered for Unity as an example, and find that Unreal Engine usually has an equivalent equal to whatever functions they use as generally the math for all these algorithms at the root are the same.
dist = sqrt( (x2 - x1)[SUP]2[/SUP] + (y2 - y1)[SUP]2[/SUP] )

Not sure why you’d need a spreadsheet for a bunch of different character location coordinates (maybe you do need it for your purposes), but if you didn’t want to do it in excel I’d recommend using two arrays of vector locations (one for the first coordinate, second for the other) and using a for loop that you’d potentially store in a third array that you’d return, depending on your needs.

You dont need to use pythagoras equation to do it, because lenght function for vectors is basically that.
so substract one location from another (does not matter which order) and use length node for result.

Hi Nawrot can you please show me how this is done using the values and data above ie;
Location 1, X= 220, Y= -208
Location 2, X= -321.163, Y= -408.634

Would MASSIVELY appreciate some help, I have a few different X,Y values that I need to calculate distance from a specific point, this data is being recorded into an excel spreadsheet so don’t need it to work in game.

now you can create vector length function, or just write this as next formula

distance = sqrt(dist_vector.x^2 + dist_vector.y^2) this is POWER of two not multiply by two.

Buty spreadshets are for calculating things, look into documentation of whatever program you are using, it should have build in function for vector math.

Location is also vector, just from 0,0,0 to where object is. If you substract 2 vectors that are not location, there may be different results depending which you substract from which. Just read something about vector math adding them and substracting.

Yes everything works same with 2d vectors and 3d vectors. If you do not have finctions for 2d vector you can always change 2d vector into 3d vector, just copy x and y and set z to 0.

To Position B;
X Value: [TABLE=“border: 0, cellpadding: 0, cellspacing: 0”]

-321.163

Y Value: [TABLE=“border: 0, cellpadding: 0, cellspacing: 0”]

-408.634

Does this seem correct?

I’m VERY SORRY for being a pain but I’d really appreciate it if you could please run through the calculation with these values to determine whether I’m doing this correctly or not?

Uh let me guess, just in case.
You placed some objects on level, wrote down locations, and you want to know how far player is?
Can you write what you want to do for game, not what you want to do with vectors.

Because just for that there is easier method.

create dummy blueprint actor, lets call it marker. You may add to it some glowing ball or arrow, something that you set to be invisible in game, but visible in editor, so you can see them all in level.

place those actors where you want,

then use “Get all actors of class” and set it to your dummy blueprint actor class

then with result of that array use “for each”, you will get for loop that goes trough all dummy actors.

But there are probably multiple solutions, and i am guessing here what exactly you want do.

It supposed to display and record distance between goal (trigger) and last player position, if the player can’t get to the goal, it simply displays you were X cm away.

I think the code works and that’s kind of not the problem, I’m using the game for some player research and have a set of recorded values from the game, but I need to double check these values are correct by manually calculating each one against the values provided by the game, to absolutely ensure they’re accurate.

It’s for that reason I need someone who knows what they’re doing to look at the values I’ve got and determine if they’re correct.
I’d really appreciate your help.

Length of that vector for numbers you wrote in is indeed 577.
And yes you can set both Z to zeroes, it will not change length of vector.
Because when you subtracting 2 vectors you doing [vector_A.x - vector_B.x, vector_A.y - vector_B.y, vector_A.z - vector_B.z]
So same number minus same number is always zero.