References from overlapping actors outdated

Hey

In case this has been answered before, I apologize. Have googled my brains out…

scenario:
I have a turret that ought to track a simple pawn moving slowly across a field. Simple enough, right?

I try to do this by having a getoverlappingactors return an array of my “basic enemy” (there are multiple)
I then get the Find Look At Rotation and set world rotation to try and aim towards the target.

However: It only aims at where it first detects the enemy. Meaning that when the enemy enters its sphere, it jumps to that position. I’ve simplified it to the point where I had only the get overlapping, and print position of actor. However it still only prints the position at which the actor was detected…

And yes, im using the event tick. ive checked a thousand times…

Hello, SharpyTwo,

Try this. On your turret create an actor reference variable called target. On begin overlap, get your desired actor and set that variable to that actor.

Now, on event tick, check if the actor reference is valid. If it is, get the current actor location of your target and run the code to look at it. If it isn’t, do nothing.

On end overlap (or some event where you want to stop the tracking), just set the actor reference variable to nothing. That should clear it and make it invalid again.

Lastly, you could use some temporal interpolation at first detection so the turret doesn’t jump immediately to that orientation.

All the best.

like so? It detects when an enemy enters the sphere, and even points at where it’s at, but it does not track it. something I would expect it to do seeing as it runs that code each tick?

Wow that is strange. It should work. I just tried it and I have it working on my end. The only difference I can see is that I am getting the world location of an arrow (standing for your tank turret) and not for the actor itself.

Here is what I have:

100776-animation2.gif

Maybe plug some print nodes to the isValid outputs, to check if the reference is the cause for some reason? And also try to print the actor location again, it should be working.

And last but not least, check in your blueprint that on your actor tick tab you have “start with tick enabled” checked.

100777-blueprint2.jpg

Might have been the cause all along?

I’ve tried adding lots of print outputs, and I come back to the same thing. It seems as though the referenced actors position does not update. If i ask it to print position it prints every frame, but the same position…

Wow, found the mistake. It was that the movement of the target did not move the transform, just the single component (sphere), which in turn fooled me because i got raycast hits off’em.
Thanks for the help anyway though. No way on earth you could’ve guessed how i screwed up, and your answer let me check what did and didnt work…

Have a good one! :slight_smile: