Quick Draw Mechanic?

Hello. I am trying to set up a mechanic where when you press a button the game will find the closest enemy and shoot it like a quick draw. I can not for the life of me seem to be able to work it out. Anyone know how it can be done ?

Thanks

Read this to get closest enemy:

From there you use the LookAt node between self and Closest enemy to determine the direction of your projectile.

its actually not too hard to accomplish. though im not sure which part your having a issue with. in any case below is a example of how it could be done. the link goes to another post where i just explained about finding the closest enemy.

the basics here is you make an array of the enemies in range (i used a overlap here), then you compare their distance to the player via a loop. while doing this you also record the closest enemy as you go and on each iteration you compare the currently being tested enemy to the current closest. once the loop is done you will have the closest enemy at which time you rotate the character to face the enemy. i used a set rotation here but you could use a lerp or interp or another method to turn over time. i used a find look at rotation to get the needed rotation. then the final step is to shoot which i just used a custom event since it will depend on your particular setup.

haha guess you were quicker on the draw than me on posting here.

Ah thanks a lot. I think my issue was that i was over complicating it in my head and from that i just couldn’t work out where to go. Thanks for the help

Thanks man. I didn’t realize someone had asked a similar question before. Thanks again