Check if Array contains a *similar* vector

Greetings. I have a Vector Array which stores the positions of certain actors in my game. I know how to use the CONTAINS node to check if an exact vector is found within that array, but what if I want to check if the Vector Array contains a value close to my input?


Imagine a Tic Tac Toe grid, with each column and row spaced 100 units apart.

  • Top left space X: 0 Y: 0 Z: 0
  • Center Space X: 100 Y: 100 Z: 0
  • Etc.

Now, when ever a player plays an X or an O (actors) in one of the tic tac toe spaces, I store the position of their marker as a vector in an array. But in the case of this example, their actor might not have been positioned precisely, so the center space may be recorded as X: 98 Y: 105 Z: 0.

So I need to set a tolerance, lets say 20 units, so that I can essentially have the logic that results in:

  • Is Vector [X:98 Y:105 Z:0] within 20 units of vectors contained Contained in Array? (Vector X:100 Y:100 Z:100 results in an output of TRUE)

Is there a simple way to do this?

There is no way other then loop thru all items and check each if it’s similar, if you find first one you break the look. It’s still simple since you. It still should be simple since oyu can just use ForEach and this node which you can set tollerance

Not sure if you can break look in blueprint. BT performance might be issue so if you can you should implement this in C++ or wait for that blueprint to C++ compiler, but it might not be a issue try it out and check blueprint time in “stat game”

It’s not like UE4 or any other C++ library could do better, we don’t have quantum computers and CPUs still do linear sequence of instructions which can check only miniature portion of memory or else x86 CPU has native instructions for that can find similar values in bigger portion of memory ( don’t know much of x86 assembler). Still doing this in BP hit performance 10x harder

Alright, I think I can manage to do it ‘the hard’ way then. Was just hoping there was a node that I was unfamiliar with that simplified the process.

Thanks for the response!

Hi, is there any reason you don’t want to use a triggerbox that would span the size of your tolerance? That way you could get the exact value for the vector every time by letting the triggerbox inform you about the position it is related to.

Anyway I attached a way to utilize nearly equal in a foreach loop on the vector array to look for numbers that are close to the number you are looking for. Keep in mind, however, that this operation will be more expensive the longer the array is.

Thanks for the suggestion =) I considered using triggerboxes, and perhaps that is actually the best way to go, I don’t know. I’m somewhere between a novice/intermediate level user, and my main concern was over-complicating my blueprint network by adding additional elements (ie, triggerboxes). The Tic Tac Toe example I gave was a hypothetical, my actual node network is pretty huge, so I was hesitant to go that route.

But thanks for that screenshot, I might play with those nearly equal nodes, I haven’t seen those before.