distance to the crossing of 2 lines (Line Trace)

eldany.uy solution should work fine :slight_smile:

and you can choose the threshold.

1 Like

I’m really confused now. Why 2 “Line Trace by Channel” in one actor? there are 2 different actors. In each actor there should only be 1 line trace by channel

one trace for each actor. the logic/blueprint depends where do you want to do it.

1 Like

this will work as long as your two actors hit the same or almost the same place. or do you mean something like this ?

both do line trace and hit the wall but the intersection is somewhere else ?

If I were you, I will solve it using simple algebra (find two vectors intersection):-

  1. Form a 2d vector for both (using their normalized directions). 2d vector can be formed by eliminating the ‘z’ component.
  2. You will find the point where both intersects - then this is easy as you can calculate the magnitude (length) between two points.

Without a wall.

ok then is best like Syed suggested too to calculate it via algebra. in the videos above the calculation is explained, just throw in the values and make it without z axis. you could take the median point later if you so prefer.

other question, needs it be in 3d space (exact overlap in xyz) or just from top down (xy)?

just from top down

ok,
i try making a quick example… can take up to 30 mins, have too look after the kids first :slight_smile:

Thank you so much!

ok,
we will make kakao and then go to sleep :smiley:

only one more thing, so you said without walls, then it could be that the line trace did not hit anything? so it´s at its max distance but has not found a suitable target for its hit ?

yes

ok now i get it :slight_smile:
a few minutes, then i open the editor :+1:

ok sry took a while, back with some example soon :slight_smile:

i am so sry, all kids are awake now and i do not have time atm, ill promise you i post i later… in max 1 hour is bed time :slight_smile:

cheers

A quick way assuming actors wont pitch:

Hope it helps.

2 Likes

hi,
sorry for late reply but here it comes ^^
(edited a few times, images are below to download, you cant see much on some)

a quick overview before we start…





one hits something the other does not

both hit the same target but notice the intersection is inside the cone

an here you see you can look even after hit if the line trace has an intersection

ok lets do it :smiley:
lets start with the line tracers…

this is your actor who fires a line trace. note the actor has an variable called ID, which is a simple INT. ATM there are only 2 IDs available, 0 and 1 but you can expand as you like.
this has the purpose to save the values for the marker, you could just fire the LineIntersect function when you know your 2 lines.

if you do not want intersections happen if something was hit, change the line trace from trace end to impact point.

here in my Gamestate (you could put it somewhere else) i made this function to store the lines so i can get my marker to show up. this is not required. it has the LineIntersections variable which is an Vector Array with 4 entries (line a start, line a end, line b start, line b end) and LineIntersectionX which is simply a Actor for the marker like in the pictures.

ok lets start with the main actor :stuck_out_tongue:

this is a function library, so we can access this function globally.
the local variables are needed for calculation, i mean you can let them out but then you will end up in spagetti nightmares :smiley:

ok here is the function, i made it out of several pictures, it wont fit on one screen to read…

please excuse the guerilla style snipped here ^^

this is the main function for intersection 2 lines. i made the same in unity but here i used an other algorithm, it is based on an algorithm in Andre LeMothe’s “Tricks of the Windows Game Programming Gurus”.

hope this points you in the right direction, z i the average point ATM but this can be tweaked :slight_smile:


as i said before you can only take the line intersection function, subtract your actors location where you like to know the distance from the intersection point :slight_smile:
in this picture i just took the start of line A.

i hope this helps you out, would be better to make a c++ function but by the time i have not setup everything to do so…

cheers :vulcan_salute:

here are the images in rar
images.rar (3.5 MB)
i see there is a problem with larger images, they get scaled and you cant see anything :frowning:

2 Likes

It’s an incredible solution! Thank you for taking so much time for me!

Please mark his post as the answer… yeah kudos to him…

:cool: thread. Are you guys reinventing the line?

:wink:


edit: I’ll just add that rather than tracing you can use the above to find out if tracing even makes sense.

3 Likes