Line Trace to Hit Actor then miss actor

Hi all, I have a line trace firing every 0.3 secs and when it hits the actor it decrease its energy in increments of 10 which is all good however what i would like to now achieve is if the line trace starts to hit the actor the energy reduces which it does but if the line trace misses while it is reducing energy set the energy back to full.(So basically you have to keep the aim on actor until energy =0 or if your aim is off target energy resets)

So my problem is once the line trace starts hitting an actor how do you say line trace now missed actor? probably a bit of logic but can think what to do…Any help will be much appreciated

If i got it right this should be quite easy :slight_smile:

As soon as your line trace hits an actor, set a variable with the actor hit.

Then, as soon as your line trace misses AND that variable isValid == true, call a function to reset the energy to full and unset the variable.

If you have problems coding it with this text-logic, i can try to do some BP mockup later when i am at my UE PC :slight_smile:

Cheers,

Hi Thank you for the reply here is a screen grab of the current BPs but if you can show what your suggested in BPs that would be great

Take a look at your cast after the branch in the middle of your graph (Cast to 0_base).

  • If this cast fails, that means you
    hit something, but not the character
    you were looking for. You’d set
    freeze health back to 100.
  • In addition, if the branch before
    that cast returns false, that means
    you hit nothing at all with your
    trace, and you would also set freeze
    health back to 100.

On a side note, I noticed you’re casting to 0_Base in your 0_Base graph. Is there a reason for that?

Cheers Guys I had tried cast and is valid just before the orig cast and it didn’t work but on removing the blocking hit branch before it, the is valid worked! yeah but then on reading your post Mookiez i re added the blocking hit and did what you said and works… MANY Thx to both you guys!

Regarding the 0_base that’s my base character which all other characters are children of. I followed the blueprint multiplayer tut and im working on top of that