Compare hit locations to each other in multi line trace

HI all

Im using a multi line trace to find if there are a crate/s in front of my character,
But needing some advice on how to approach comparing each vector to the previous one in the array. during the loop process
So for example if the hit location returns a distance bigger than a amount i want… (ie) There is a gap between the crates…
Therefore allowing me to know, this one needs to be ignored.
Any ideas?

can anyone help

First of all, please don’t bump questions that aren’t unanswered for at least 4 days! Otherwise this will make the answerhub confusing.

So to solve your problem. A multiline gives you an array of the objects that were hit. So you could move through this array with a loop and breaking the Array Element. Then you would need a variable to store the last hit location and just compare the current hit location with that variable. After that, you store the current hit location in the last hit variable. Just make sure you only compare if the current index is greater or equal to 1. Because the first hit has nothing to be compare to.

If you need an image for that setup, just tell me. (:

Yes ok, sorry for bumping,
It would be very helpful, if you could show a screenshot of the process, will give me a better idea.

Something like this for example:

I don’t know your exact setup, but i think you will get the idea behind it (:

Thank you for the image…
im gonna try to explain some more so you have a better idea.

So i have a character that can kick boxes a set 100units, per kick, because everything is on a grid. and of course when you kick the boxes around you can end up with the boxes in a line/row
So before player kicks the box im tracing out into the world checking if there are other boxes in its path and if they are all lined up correctly and have no gaps they should all move… i already have this working. but i need to know how to find out if there is a gap between my boxes.

ie when the hits return from my trace i save the location vector of each hit into a array. which i was then planing on somehow while looping figuring out if the hit location from each other in the array has more than a 100 units from its previous index, then that would allow me to know that oh that box is to far away so should not be included in the kick,


Yeah ok, this should be possible with my solution. You could check the x, y and z value of the “Get Direction Vector” return value and check if they are less than 100 etc.

The direction node does the following.

  • Vector1(100,200,0)
  • Vector2(200,200,0)
  • Vector3(400,200,0)
  • Vector4(500,200,0)

Let’s say these are the positions of your boxes. Since it’s grid, you know they are aligned along the x axis. There is a gap between the second and third one.
So now, the distance between these would give you

(200,200,0) - (400,200,0) = (-200,0,0)

If you would check this return vector now, you would just check the x,y,z value for being bigger than 100 or less than -100. For this example, it will be true and you know there is a gap.

Just drag the return value into an empty place and type “break”. Then you should be able to break the vector into the 3 axis. Then you just make a branch with an OR node. Make 3 greater and 3 less nodes and plugin the x into one greater and one less etc. Type in 100 for the 3 greater once, and -100 for the 3 less ones and plugin all returned bool values into the OR node (you can add pins to the OR Node).

:X This should work so far. Could be that there is a easier solution, but i can’t think about one for now.

Would you mind printing out the HitActor name. Seems like it is hitting the same box.

Yes thank you… i must be doing something wrong, because the get distance vector always returns 0.0 no matter what i do.

If i understand correctly… it returns the display name of the 3 boxes but 0.0 for each one

Okay the reason for the return value of 0.0 with the get distance vector seems to be because the last hit location is always the same value as the value entered into the “from” pin.

Öhm, ok. So it hits different cubes but the location seems to be the same. You could also print both vector, just to be sure.

AH, i could have made a mistake! Please try pulling out the HitActor and using “Get Actor Location” instead of the hit location. Because you want the actor location and not the hitpoint. Although the hit point still shouldnt be the same.

yes i thought the same hit location should work as well… but the routine that is setting the last hit location variable is the same as the value being passed to the “from” pin and of course if there are the same. we get 0.0… i need to make sure the value i set in the last hit location var is the one before the one im checking in the loop?

Hm yeah, it’s pretty late in germany. I will have a look at this tomorrow. I don’t know why the position are the same.

Either they are really the same or something with the variable is wrong. Although i don’t know what. This is just a regular algorithm to check 2 items of an array… hmpf.

Ok so i have your example working with minus node from last hit location var and hit actor location rather than your get distance vector, and i get the difference in the distance between the boxes, but this is not dynamic. i need it to be… because i may have any number of boxes in a row. so i need to figure out a another way of storing the previous value from the array and checking it with the next index value.

This should still work. If you have multiple boxes in a row and there are gaps in between, the method should print “Different” as many times as a gap was found :X Could you explain why this is not working for you?