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"

How to hit Mutliple Actors with one Trace?

Silly question here, but I have been having issues getting something work. I have a character apply damage on a click and then check to see if it hit. If it does, it applies damage. That's well and good, but how do I get it to hit multiple different targets at once? Right now I have it run the check 3 times and add any previous hits to an array to be ignored, but surely there must be a better way?

Thank you.

https://i.imgur.com/vSjePoL.png

https://i.imgur.com/Q7Iw3HO.png

Product Version: UE 4.17
Tags:
more ▼

asked Jun 06 '18 at 03:53 PM in Blueprint Scripting

avatar image

Aggroed
17 4 2 6

avatar image Nebula Games Inc Jun 06 '18 at 05:12 PM

Those images are pretty bad. But I am not sure what your issue is. You use a muti-sphere trace, so that will give you ALL hits during the trace duration. Just get the out "hit actors" and apply damage to each one of them...seems like you got it. I dunno if the issue is it is not hitting all different actor types as I see you only have "pawns" in the first image for the actors to trace against array, you can add multiple actor types to that array and it will return hits for all listed class types. Again, very confused here.

avatar image Aggroed Jun 06 '18 at 06:31 PM

All of the actor types are the same. I can try to get better images if they would help explain.

What I am trying to do is hit multiple actors of the same type. It will only hit the first one it finds, unless I have it redo the logic again and add the hit actor to an ignore array.

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

1 answer: sort voted first

Multitraces are stoped once they hit a "blocking" obstacle. If you trace for pawns and their collision is set to block, the trace will stop once it hit a single pawn. What you want is a new collision channel that does not block your trace but is set to overlap only, that way your Multitrace will continue after hitting (overlapping) the first pawn.

more ▼

answered Jun 06 '18 at 06:13 PM

avatar image

soannoyed
51 1 4 9

avatar image Aggroed Jun 06 '18 at 06:32 PM

I've looked over the pawns and none of the collisions are block, they are all overlap or pawn collision. Could you elaborate further? Thank you

avatar image soannoyed Jun 06 '18 at 06:43 PM

If you still use the setup you pictured above, then try to remove the branch after the trace and instead of a get use a for each loop on the "Out Hits" array. In case you haven't seen it, theres also a good video example of it https://www.youtube.com/watch?v=v-7_l_ZYKq0

avatar image Aggroed Jun 06 '18 at 09:32 PM

That worked, thank you!

avatar image Nebula Games Inc Jun 07 '18 at 12:14 AM

Looking at this again I see the issue. Multi-trace does not "stop" after the first hit, that is the whole point it will collect "multiple" hits and put them into an array. A single trace will stop however after the first blocking hit. Your issue as @soannoyed pointed out is the "get" node. You have it hard coded to "get" index 0....EVERY time. So you will only ever get one "hit" with applied damage with that set-up no matter how many "hit" results your trace returns. The for loop is the way to go as it will run your code for each index in the array and apply damage accordingly.

(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