Get Vector3s in range
Hello guys,
I want to make it simple for your and my sake
I just want to know the technique of getting the Vector3s in range from an array of Vector3s
I'd prefer Javascript but C# will work too
Just tell me how it works and should knows or even links to tutorials or the manual
[INFO]
[Unity 5.4 (Older will do)]
[I Have Hundreds(Maybe Thousands) of Vector3s]
[My Game has IMGUI And custom editors]
[If you want the script I can give it to you, just comment]
if(v.x>5) v.x=5; is one way of getting them in range, if x past 5 isn't in range. Obviously, the problem is "in range" could mean anything. If you figure out how you need to fix them, you'll probably be able to Search for how to do that.
Answer by tanoshimi · Aug 22, 2016 at 05:56 PM
If your candidate vectors are in a simple array, there's really only one approach:
loop through the array
calculate the vector difference between each item in the array and your "target" vector3 (V = Vectorₓ - Vector₀ )
calculate the squared magnitude of the difference (V.sqrMagnitude)
if this exceeds the square of your "range", discard the candidate, otherwise keep it
move on to the next item in the array
Thanks alot
The answer i expected was different but I think this is the only way
Your answer
Follow this Question
Related Questions
Saving old Position 1 Answer
Quick question with a Camera Following script 1 Answer
Need help with multiple updating transform positions 2 Answers
Moving an array of Vector3 with the GameObject (Path-System) 0 Answers
Unique list of Vector3's 1 Answer