Download

Following a Hourences tutorial: Multiple items highlighting on line-trace.

I’m kinda clunking through one of Hourences videos- (which are amazing!)

I’m not sure if I’m screwed up or his methods just don’t cover this situation;

Where he has the blueprints set up to capture the single line trace for object highlighting- if you trace over multiple items which are close together, it never triggers the “renderCustomDepth” material to shut off. This leads to multiple items being able to be highlighted at once.

This seemed like a good opportunity for me to break away from his video, and try to find a solution on my own. While I did find one, I’m not sure if it’s really the best way to handle the problem. I feel like there’s probably something really simple that I’ve missed which would require far less instructions.

Here’s what I have: http://i.imgur.com/a2MHP5d.png

Any input would be appreciated!

Suggestion:
Make a variable containing your last highlighted item.
Make a check to see if the object of the line trace is the same as the last hit you got. If it is, highlight still… if not, un highlight last object… and highlight new

Huh… Yah I’ll give that another shot then.

Initially I thought the same thing, but couldn’t figure out how to do it without looping through an array.

I make the lastitem variable (assigned by the currentitem variable somewhere). But then I run into problems when comparing- as the “lastItem” always seems to update to whatever the current item is. -that seems like an obvious problem, but I can’t seem to wrap my head around where to update “lastItem” where that doesn’t happen.

Success!

I finally got it. Thanks for the suggestion Rasped. I’m pretty sure this is much more efficient than my array method.

Awesome! It looks good, I like that you comment everything, I could learn something from that

Yeah I didn’t do that part in the video to keep it simple. I have this working correctly on my end in the actual game, and my solution is identical to what Rasped suggested.

Didn’t look in detail at your pic but it looks a bit intense though. Before the Set Item In View happens the variable Item In View already carries the previous item in view. Therefore all I do is just compare Item In View to current output of the trace. If not equal, then I first turn off custom depth on Item In View before defining it again with the new item. I have just 4 “blocks” more than before that way.