How do get information, such as 'actor location' using 'actor has tag' ?

I’m making a tower defense game. I’ve an enemy which has the tag ‘enemy’ and a tower which has a sphere. Anything with the tag ‘enemy’ that overlaps this sphere is supposed to be shot at. I used the function ‘On component begin overlap’ and I’m looking for anything with the tag ‘enemy’ like in the image


I want to know the location of the actor with the tag ‘enemy’ that overlapped the sphere. How do I do this?

Assuming only one actor will at a time:

2 Likes

This gives the enemy fixed location, but the enemy is moving. How to update its location?

You’ll need to store a pointer to that actor and get its location in Tick or a timer.

Why is this not working? It seems that the overlaps trigger twice and it stops. So I added a loop so the tower keeps shooting. But this way the location is not updating. Care to elaborate on how to fix this please?

My guess is that the pointer to the actor is no longer valid so it doesnt know from where to pull the location.

I created a variable of type ‘actor’ then placed the enemy actor inside it. This solved the problem.

1 Like