References from overlapping actors outdated
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...
asked Jul 30 '16 at 12:11 PM in Blueprint Scripting
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.
answered Jul 30 '16 at 12:24 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here