Hello all,
I’m InformerHyena.
During my free time I am trying to develop a MOBA.
I am currently developing the turret/towers and I managed, by following a tutorial, to get my tower to detect the closest target and shoot at them repetitively until they die or leave the range. However i noticed that, if player 1 enters the area first, the tower will attack him, but if player 2 gets ahead of player 1, the turret will change target to player 2, instead of remaining aggroed to player 1.
What i basically want the tower to do is:
Get the aggro of the first player (or pawn) who enters the area
Shoot that target until it leaves the area or dies
Check for new target (closest one in this case)
But i have really no clue how to make this work.
Any suggestions are very much appreciated.
You can avoid targeting another character if you just check if Current Target is valid, and probably also alive, before calling Find Best Target. So basically, if you were to continue using your method, inside Tick, only call Find Best Target if your current target is not valid or dead, otherwise just do the rest.
I think something like this will work for you as a quick solution. There are more things that you should do, or probably do differently. You could use a sphere collision and check for targets in begin overlap instead of doing it on tick, and you should probably have a function that also checks if the target is alive and targetable, or bind to some event for when they die to clear the target.
For the actual firing, you can use a Do Once node and then a delay with your rate of fire to reset it, instead of saving the time, should be cleaner.
Hello, I have a few updates.
I followed some guide for the sphere collision, as you mentioned.
However I am very lost because the guide makes the turret target always my ThirdPersonCharacter, meaning that I will always be the target.
How can I make it so that it targets a class or tag?
My idea is to have all characters and paws from Team A under the class/tag “blue” and the other team under the class/tag “red” so that the targeting for each tower will check whether they are red/blue and target accordingly.