UDK Auto-Turret (Reset Target)
UPDATE: There has been a consistent problem that the turret only causes splash damage while projectiles seemingly pass through the player. Thanks to Mr. Shamalinia this has finally been fixed! The solution is to use an unknown object (marked as “???”) for the Spawn Projectile instigator input, not the instigator output by the player spawn event. Attaching a Dynamic Volume is also no longer necessary. I will be rewriting the tutorials to include these changes soon!
The following tutorial is to be read as augmentation to the core setup for an Auto-Turret in UDK, which is outlined Here. As with the previous tutorial, this tutorial is intended for users moderately familiar with the Unreal Engine and Kismet.
Reset the Turret-Target Location on Respawn
In the situation that the player is killed by the turret, and then respawns, the Dynamic Volume (labeled as “Target” in the tutorial images) will remain attached to the player without relocating to the player’s active spawn point. In this way, when the player approaches the turret again, the turret will still be firing at the target, and not the player.
To fix this, upon player spawn, the target must be reset to the active Player Start. The Set Actor Location action is all that is necessary to accomplish this. Connect the Set Actor Location’s Target variable to the Dynamic Volume labeled “Target”. Find the vector coordinates of the active Player Start (open the Player Start properties, open the Movement category, and open the location section where the vector coordinates can be copied). Then create a vector with corresponding coordinates and connect it to the Location variable of the Set Actor Location action.
If there are multiple Player Starts, instead of using a Set Variable action to correct the Dynamic Volume’s vector after each checkpoint, an Object Comparison of the Player Starts will allow for a more organized function. To do this, create an unknown Object (Marked as “???”) from the Player Spawned event’s Spawn Point instigator. Then create an object for the Player Start. The Player Spawned event will always output the last used Player Start. Create a Compare Objects condition, connect the unknown Spawn Point instigator to Object A, and connect the Player Start object to B. Now create a Get Location and Rotation action. Connect the A == B output from the Compare Objects condition to the input of the Get Location and Rotation action. Connect the B variable to the Target variable of the Get Location and Rotation action, then connect the Location output to the target reset vector of the Set Actor Location action.
If checkpoints are not a concern, a similar setup may be implemented in which the Compare Objects condition is not necessary. This setup is visible in the image below. This is especially useful in situations where multiple spawn points exist, such as arenas, because the Dynamic Volume will reset accordingly regardless of where the player respawns. However, this method will not work for multiple human players.