Announcement

Collapse
No announcement yet.

Target lock (can i test if variable is empty and empty again?)/Target Highlight (thoughts)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Target lock (can i test if variable is empty and empty again?)/Target Highlight (thoughts)

    I recently moved my twin stick shooter to a single stick.

    But now you can tap the characters and lock on.
    Works fine most of the time.
    I have an object variable, that on begin play is set to the character himself.

    Target-able objects include the "on touch" event node and change the object. Event tick look at rotation is used to face the object.

    Only problem is i do get an error. When the PRE ticks trigger the object is empty and (event begin play sets is to character) and so rotation is found to be none. Game still playes, But i worry about the errors...

    Rather than checking if the object equals self I would like to check if it is EMPTY and just make it empty when not targeting. Is there a way to do that?

    I guess I could deal with having it set default to the character, but the default value is grayed out in the BP.



    Also when targeting an enemy I would like it to have a circle around them or whatever.
    I have thought of several ways to do this, but they require event ticks and such. And was worried a bit on the performance.

    So far my favorite is to create an object that is mostly transparent, with a red circle, that would attach to the enemy.
    I have considered trying to do a dynamic material that would alter a gradient giving you the enemies current health....
    thoughts?
    Has anyone seen anything like that used? when i search I mostly get results for FPS targeting systems

    #2
    Nor sure what you mean but there is something called "is valid?" And you can plug this into a branch. That way you would know if a variable is empty or a character is no more, etc

    Comment


      #3
      Originally posted by Muntrax View Post
      Nor sure what you mean but there is something called "is valid?" And you can plug this into a branch. That way you would know if a variable is empty or a character is no more, etc
      Thanks i'll give that a shot. How I do it now it gets bit weird some times. First moment of loading, since it has pre-tick (i dont know if i can turn that off?) it of course comes back "target != Self, TRUE" and so tries to set the Pawn's rotation. Which is based on the "target" so comes back error....
      Before the Begin play sets the variable to "self". It occurs several times. Doesn't seem to effect anything but, i do worry what MIGHT happen if it keeps it up on a system that doesnt like it.

      And when a target dies, or you "unlock" your target it sets the variable to the player pawn. Works MOST of the time. But every so often rather than getting the pawn, it likes the player start point. No idea why this happens maybe 10% of the time. And then you are rotated to the origin of the player until you find an enemy you can lock on to

      Comment


        #4
        Hello,

        About your issue, without a search in blueprints it will be hard to help especially when trouble is "most of the time"
        This can be a mistaken link like in a loop, using body to exit instead of completed, a branch not set in right place and sometimes only the engine which needs time (i had a project with a blueprint not working until i put a delay of .1 on begin play to let time to other blueprint to do the job)

        About your visual on enemy, there are differents ways you can use like
        outlines https://www.youtube.com/watch?v=BWoVkQjYncY (or with post process too)
        selection circles https://www.youtube.com/watch?v=uwi6UDiNNX8 (may not be ok for you but good to know)
        or widget in character visible only when character is targeted showing an image or an animation with color changing like https://www.youtube.com/watch?v=MHnEIIvLYBc (but with widget in character not in umg)

        Comment


          #5
          Originally posted by Fen View Post
          Hello,

          About your issue, without a search in blueprints it will be hard to help especially when trouble is "most of the time"
          This can be a mistaken link like in a loop, using body to exit instead of completed, a branch not set in right place and sometimes only the engine which needs time (i had a project with a blueprint not working until i put a delay of .1 on begin play to let time to other blueprint to do the job)

          About your visual on enemy, there are differents ways you can use like
          outlines https://www.youtube.com/watch?v=BWoVkQjYncY (or with post process too)
          selection circles https://www.youtube.com/watch?v=uwi6UDiNNX8 (may not be ok for you but good to know)
          or widget in character visible only when character is targeted showing an image or an animation with color changing like https://www.youtube.com/watch?v=MHnEIIvLYBc (but with widget in character not in umg)
          The "is valid" node seems to fix those problems.
          Code was simple.
          Event tick--->if object != Self ----> get look at rotation of object set pawn rotation to it.

          I didn't know about is valid so I was just setting the target variable to the character if I wasn't locked or if the enemy died.
          This way I just check ''is valid".
          As I haven't found way to remove the info stored in the variable to leave it empty I still make the button that removes target lock set it to self and, left a second check "is valid and not equal to self".
          Worked out perfectly.

          My guess is when enemy pawns died and sent the command to set the target to the pawn self, it was probably occasionally getting the characters spawn rather than current position.


          Targeting circles are exactly what I wanted.
          Wasn't sure how to set them up without a whole bunch of checks and event ticks. Then getting rid of them because I was thinking of attaching them to the target actor...
          Only thing I didn't see there I was thinking of using was trying get the circle to also work as health bar. I figure when I get home and really look at it, I can probably get it set with a gradient that is set to the target's HP%

          Also thanks for the animation link. Was thinking about floating numbers and that looks like it will be in the right direction for that.

          Comment

          Working...
          X