I’m learning and fooling around with Unreal Engine 4 and I’m trying to make a turret that fires at the player in the “Twin Stick” - prefab.
This is my BP for the EnemyAIController posessing the turrets:
In my head everything should work, they even rotate correctly to face the player and also register that he is in range, but they don’t spawn any projectile.
There is probably a better way to achieve this than my BP, but I’d like to understand as to why this doesn’t work.
Thank you!
The one thing that immediately stands out is the timer being set every frame. The function would like to execute in 2s but before it can, Tick fires the timer again, resetting it. It never gets to fire.
Essentially, this will never execute since we’d need to wait 2s for that:
And it gets restarted 60 times per second (or more!)
Ah okay, that makes total sense now that you point that out. Thank you!
So, the best approach would be to make a collider trigger that sets a timer which loops as long as the player is inside the collider, right?
That would be my next approach now.
That’d be the best method as it does not rely on Tick.
Begin Overlap → Start Timer
End Overlap → Stop Timer
The turret tracking player position must tick since we do want to update it every frame. Also, if you do not want to wait 2s for the first shot, you can try this: