[img]https://i.imgur.com/CNtPQJw.gif[/img] Hi-res: https://gfycat.com/pl/heftyobedientguineafowl Hi! Welcome to another installment of the series about defensive towers in The Riftbreaker. Last time we covered the basics of their behavior which are common for every turret type. However, there are unique, individual characteristics for each type that make them into what you will see in the game. [img]https://i.imgur.com/juDPNDQ.png[/img] [code] TurretDesc { target "ground_unit" speed "300" aiming_cooldown "1" aiming_target_time "2" aiming_idle_angle "20" pitch "be_barrel" yaw "be_turret" check_target_visibility "1" aim_volume "SphericalAimVolume" { range_min "0" range_max "30" aiming_range "40" } } [/code] First, let’s take a look at the Sentinel Tower. It is the most basic defensive tool that you are going to use in the game. You can build them without researching anything, as they are available right from the start. They are relatively cheap and do not require any special kind of ammunition, as they simply fire energy projectiles which consume the same energy as any other building. If you build too many of them, however, your power grid might have trouble keeping up with the spikes in electricity consumption, so bear that in mind. [code] weapon_definition "ProjectileWeaponDef" { fire_rate "0.35" fire_effect "effects/weapon_fire/mech_minigun" FirePattern { burst_column_spacing "0" burst_rate "0" burst_rows "1" burst_column_angle "0" burst_columns "1" } ammo_storage "energy" ammo_cost_per_fire "10" } [/code] The energy bolts fired by the turret are treated by the game as projectiles. They are only one of the possible types of ammunition in the game. The way projectiles work in The Riftbreaker is based on raytracing. As the tower tries to acquire a target, it projects a single ray at it and checks whether there are any terrain obstacles along the way. If there are, it will not fire in order not to waste energy. [img]https://i.imgur.com/vaiSA0q.png[/img] [i]Lack of ammo doesn't stop these from helping you in battle.[/i] If the target is valid and the ray trace is not obstructed by anything, the tower will start shooting, one energy bolt at a time. That’s easy enough if the enemy is standing still, but if they are moving, we need to employ some other techniques. An algorithm takes care of it. Taking into account the speed of the enemy unit and the speed of the projectile it calculates the projected place where the two paths will cross. The tower will aim at that spot, trying to intercept the enemy with its bullets. [code] WeaponMuzzle { attachment "att_muzzle" recoil_bone "be_recoil" recoil_time "0.35" recoil_offset "1.0" } [/code] With all these systems in place, we have a tower that can move its turret, acquire targets and shoot at them. To make the weapon complete we have to add some extra effects. First of all - the recoil mechanism. In order to add the kickback to the shot, we specify which element of the model is going to get pushed back. Then, we specify how far back and in what time the barrel of the gun should travel. Getting it right requires a lot of tweaking, but it is vital to the feeling the player is going to get while seeing the tower in action. [code] weapon_emissive_affector { emissive_time "0.35" emissive_factor "60" submesh_idx "1" } [/code] The last thing that we need are some cool lighting effects, you know we love those! As the tower shoots, it triggers what we call an emissive affector. The emissive material is, broadly speaking, a special kind of texture that emits its own light, regardless of other light sources that are present on the scene. The trick here is that we want the towers to light up only while shooting, and the affector takes care of that. It tells the game which parts it should illuminate and how quickly it should do it. It is controlled by the parameters you can see above. Finally, we can call this tower complete and ready for action! Thanks for reading this piece. If you enjoy stuff like this, make sure to join our Discord at www.discord.gg/exorstudios. We love connecting with our players, so come and chat! It’s also the place where you will be able to sign up for the closed beta when the time comes. See you next time! Other social media: www.facebook.com/exorstudios www.twitter.com/exorstudios www.mixer.com/exor_studios www.twitch.tv/exorstudios