Actor look at spawned actor

Hi,

I’ll try keep this as short as possible, i’m making a tower defense game and i have managed to implement the spawning of the enemy ai and navigation. I have also managed to make my tower cannon face my player with Find Look at Rotation for testing, now i need to find out how i can get my tower cannon to face the nearest enemy ai which has spawned and ran by it (i have the range covered).

or in short, how do i get one actor to face another actor which has been spawned?

I can’t test this out atm but you could try having a sphere component to your tower. Also create an Variable of Actor Array. Have Begin Overlap Event from the Sphere Component. When an enemy enters the sphere, add it to the Actor Array. This is so that you can track multiple enemies enter the tower range. Now get the tower to target the first index of the actor array. Before the turret shoots, check if the target is valid, if it isn’t, it means the actor has died. Remove the element from the array and target the next one. Now you also need a End Overlap Event event from the Sphere Component to remove the enemies from the Actor Array when they exit the Sphere Component which is your range.
This is just an ideal.

Also, if you go to the Learn Tab of the UE4 Launcher and scroll down, you can download the Strategy Game Content Example which I think is a tower defense game. You could see how they did it, thought they may have used c++ for that mechanic. Check it out!

managed to get it to work :smiley: check out the screen, awesome, thanks :D!

Awesome! Glad to hear you got things under way :slight_smile:
I wish it wouldn’t convert the thread to Not Accepted from leaving a comment. I really wanted to tell you great work! Well I guess you have to accept the answer once again now :stuck_out_tongue: Sorry!

Np. We can take care of that :wink:

Never hesitate from commenting like that because of this! That’s more than fine and if we should ever oversee it just pm me on the forums.

Cheers :slight_smile: