Need Help With Target Lock System on Enemy


Here are the blueprints that I’m using. The blueprint is working but, only on ONE enemy unit. When I try to add 2 enemies in the stage, player character tries to lock on both of them at the same time, which breaks the lock and breaks the system. What I want to do is:

  1. Lock on 1 enemy in the visible range. (There’ll be 2 enemies in the visible stage)
  2. Whenever I shoot, the projectile will hit the enemy for 3 times, and it’ll die.
  3. When the enemy that we’ve locked on dies, it’ll lock on the other enemy.

I don’t know how to do this. Please help
Thanks!

Nothing seems wrong with the code you’ve provided so far. But we should set up the correct algorithm on when to call that event of yours. There are of course many ways to achieve the exact same thing you want, though since you didn’t provide that part yet, I could suggest using line traces to detect enemies and setting a boolean type variable to be true which indicates an enemy has been located to be locked onto, then call your existing event. You probably did something similar though, my guess on why it’s not working the way you expect is that you have a single vector type variable that gets assigned to be the location of the enemy that needs to be locked onto, but you should rather have an array that stores the location of the enemies and removes them once they’re dead. And you should stop calling that function to have the player face the enemy once a location gets chosen. You can keep running that line trace part of our code that keep a track of the enemies but disable the section where we call that event with the help of that boolean type variable I mentioned, by setting it to true right after you call the event and back to false once you kill the enemy that was focused on. I hope this was helpful! :blush:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.