x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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?

Product Version: Not Selected
Tags:
more ▼

asked Nov 14 '14 at 10:54 PM in Blueprint Scripting

avatar image

soulmapp
106 15 16 23

avatar image soulmapp Nov 15 '14 at 02:25 AM

can anyone help

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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. (:

more ▼

answered Nov 15 '14 at 09:31 AM

avatar image

eXi
6.8k 333 185 468

avatar image soulmapp Nov 15 '14 at 01:19 PM

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.

avatar image eXi Nov 15 '14 at 01:32 PM

Something like this for example:

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

asd

avatar image soulmapp Nov 15 '14 at 02:00 PM

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,

alt text

untitled-1.jpg (19.2 kB)
avatar image eXi Nov 15 '14 at 02:43 PM

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.

avatar image soulmapp Nov 15 '14 at 08:37 PM

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

alt text

untitled-1.jpg (304.7 kB)
avatar image eXi Nov 15 '14 at 08:39 PM

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

avatar image soulmapp Nov 15 '14 at 09:49 PM

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

untitled-1.jpg (274.1 kB)
avatar image soulmapp Nov 15 '14 at 10:03 PM

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.

avatar image eXi Nov 15 '14 at 10:18 PM

Ö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.

avatar image soulmapp Nov 15 '14 at 10:37 PM

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?

avatar image eXi Nov 15 '14 at 11:04 PM

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.

avatar image soulmapp Nov 16 '14 at 04:29 PM

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.

avatar image eXi Nov 16 '14 at 04:57 PM

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?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question