Search in
Sort by:

Question Status:

Search help


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...

Product Version: UE 4.12
more ▼

asked Jul 30 '16 at 12:11 PM in Blueprint Scripting

avatar image

3 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Jul 30 '16 at 12:24 PM

avatar image

601 14 10 34

avatar image SharpyTwo Jul 30 '16 at 12:38 PM

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?

alt text

skjermbilde.png (140.0 kB)
avatar image Diego_Visualma Jul 30 '16 at 02:09 PM

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:

alt text

alt text

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.

alt text

Might have been the cause all along?

blueprint1.jpg (179.7 kB)
animation2.gif (4.8 MB)
blueprint2.jpg (38.0 kB)
avatar image SharpyTwo Jul 30 '16 at 04:13 PM

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...

avatar image SharpyTwo Jul 30 '16 at 04:21 PM

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! :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:


Follow this question


Answers to this question