Making variables array and compare

Hello,
Despite the tutos on the arrays, I do not really understand how to do because of my English is reduced … And my 3 neurons with;)
I have several Linetraces which I get the result “hitLocation” with a variable for each … I would like to retrieve these variables in an array then be able to compare them in order to choose the best location compared to my FinalTargetLocation and make my NewTargetLocation. …
I can do it with booleens but it’s tedious …
I continue my research and tests in the hope …
I enclose a shema of my thing;)
Thanks in advance… or not :wink:

Let’s start off basic. You don’t even need to make the array, have you seen MultiLineTraceByChannel?

Thanks for comment but It would have been nice to develop the argument, at least a little …

Sorry, your question is a little unclear. You can combine the output of multiple linetraces like this:

Your picture above, IS basically of a multi line trace :slight_smile:

If you want the trace to pass through several actors, not just stop at the first one, then multi is the way to go.

Shall I give you code to find best ( nearest ) of the trace array to your final target?

So this is how to find the nearest actor in an array of actors to your target actor:

The default starting value of BestDistance should be > length of your line trace…

Hello,
I wanted that with my linetraces, I can recover the values (end location) then compare them with the FinalTarget.
What node is needed to retrieve the value of the array that is good (with PrintString 1 is true and the other 3 are false, so it works)
And I would like that if none is true, choose the location closest to my FinalTarget (probably with a minus vector?)
By cons I do not understand why the MultiLine Trace are better for what I want to do?
I hope to be a little clearer and again Thank you for your answer

Thank you very much, even if I do not understand completely (in test it will be better), I will manage to do something with your answer and captures;) I did not consider using MultiLineTrace because the goal was to limit me to the first collisions to circumvent them without making an arbitrary choice (isforward collision = random turn left or right), but a choice based on the spatial position, even if it leads to a new collision a little later. The AI ​​must have limits of perception … Except that I thought I could choose a point of the LineTrace corresponding to a fake grid while we can only have the start and the end (collision or not) I do not think to be clear with this comment, my logic is too vague because there is too much thing that I do not master yet …
I will validate your answer even before having tested, because I see how to recover and compare the array in your 2 new captures and it answers my original question but how to do that since you only comment? If not, put an answer and I confirm …
Thank you again for sharing your knowledge.

It’s a function, so you just use it like this:

There is also MultiSphereTraceByChannel, maybe that’s more what you’re looking for?

It’s quite possible, I had seen this video of a Russian but I thought it was a little too complex for me …
Moreover is it not too greedy resource?

I’ll take a look. How many actors will you typically have in a scene? If it’s less than 20, you don’t even have to do traces…

No, my AI (Simple CubeMesh Pawn) is not the original (I would have liked to keep the original AI and can control the movements of ThirdPersonCharacter), it has its own movements that simulates a grid and its 4 directions … (The grid would have been perfect but I do not know how to generate levels Z + and -, so I opted for no grid) And when it makes a collision it remains blocked. I started with 4 Line Trace for directions, isCollision Foreward = Turn right, isCollision Left = move Forward, isNotCollisionLeft = Turn Left or isCollisionLeft And IsCollisionForward = TurnRight etc … However, it was a bit tedious and complicated with FindLookRotation … So I would like to set up a system where I control the rotation … Maybe this way will not be better, but at least I learn by practicing and developing my own logic. Once finished the AI I could finally go to the game …
thanks again

Ok, but I do not completely understand the function…In the input of the function: Target actor is my IA, but HitArray is? For me hit array is Vector … With MultiTrace output I can not connect, so I have to create an output variable that will be HitArray?
For the rest I understand the variables and comparisons that set the index to the end that is recovered when the Loop is completed.
As against output The variable NearestActor, what is it ?
Sorry for my snail brain :wink:
And please, for the next post answer not comment…
Thanks

By the way, I realised that function needs a SET BestDistance = 20000 at the beginning ( or anything larger than the length of your trace ).

Sorry, I think I just understood … Your function considers the actors to find (PatrolPoint, Character etc) … I’m looking for locations in relation to 1 actor with many LineTrace hit result…
However, even if I’m wrong, you showed me how to get the index of the array that corresponds to the different comparisons that can be imagined … Set the index at the end of the chain then get this the loop finished with the return node. In addition I think you’re right, I’ll rethink my thing with MSphereTrace or Box …
I know I’m doing too much, but I honestly think so, for once I get real help, I want to thank you again.

Thank you,
Why choose the actor rather than the location? Because the nodes allow more flexibility with the actors than with vectors?

Thank you for this new information that I will try to apply to my future reasoning …

In that function, hitarray is an array of actors.

Well, after you do your trace ( however you do that ), you will can get an array of actors from the array of hits, that’s what you put into my function :slight_smile:

I will show you a version for an array of hits…