[This tutorial is based on v2.30 edition of the toolkit, but should work for later versions as well. For previous versions of the toolkit, you can follow this tutorial: https://docs.google.com/document/d/1Et1PXlQ8xJ6n0q5Ok8BiYYpJ5BwwLdIvSC3cbuqmOPM/edit?usp=sharing.
If you're unsure about what version of the toolkit you're using, you can find this information under Edit >> Project Settings >> Description >> Project Version.]
1. First create a new child blueprint based on BP_Tower_Parent.
2. Open the newly created Tower blueprint, and set a new custom static mesh for your Tower.
Optionally, you can also set a custom static mesh for the Turret component if the gun is separate from your base Tower mesh.
3. Head over to the Weapons folder and create a child blueprint based on BPC_WeaponSystem.
As the name suggests, this component handles the firing systems for the Tower. As an optional step, you can then move this new component to Towers >> WeaponSystems folder since that's where you can find all the default tower weapon system components that comes with the toolkit.
4. Now what we do next depends on what kind of Tower you want to create. If the tower firing behavior involves locking on to and firing at a single target at a time (eg: Machine Gun Tower), then we want to override the FireAtTarget function within the new weapon system component we created in previous step. On the other hand, if you want to create a Tower that does AoE damage to all units in range (eg: Shockwave Tower), then we want to override the FireAtTargets function.
For this tutorial, I'm going to go ahead and override the FireAtTarget function as shown below:
You can write your own custom firing logic here based on the kind of Tower you had in mind.
I'd also suggest checking out the FireAtTarget/Targets functions within the default weapon system components to study the firing solution implementations for other Towers. As starter examples, BPC_WeaponSystem_Hitscan and BPC_WeaponSystem_SphericalAoEBlast components are quite straightforward and easy to understand.
5. With the firing logic taken care of, the next step is to set up the high level behavior of the weapon system. Like what kind of targeting model is being used to track targets, whether it can fire continuously, and the firing trajectory used to reach the intended target. The code for these are all implemented already, so we just need to specify the type so that the Tower knows what to do. For this, select Class Defaults from the top toolbar, then go to the Config section under the Details Panel, and set these three parameters as per your requirements.
5. Finally, we are going to create child components based on the custom Weapon System component that we just created, such that there is one child for each Tower that uses this weapon system. Say, for example, if a Machine Gun Tower and all its upgrades use the same weapon system, then we'd want to create a child weapon system component for each of its upgrade level as shown in the next screenshot:
Now we can go into each of these child components and set up unique weapon stats on each of them through the variables listed under Stats >> Base category as shown below:
6. Next, open the enumeration ETowerModels and add a new entry for your new Tower.
7. The stats for all Towers in the toolkit are set through data table entries. So we're going to open the data table DT_TowerData and add a new entry for our Tower here.
Make sure to set the "WeaponSystem" parameter to match the weapon system component associated with the Tower. It will automatically handle spawning in the component when the Tower is constructed during gameplay.
9. Finally select the BP_TowerManager actor from your level and the new Tower enum entry to its BaseTowerModels array from the details panel.
And
that's it. You have now created your very own Tower. All the UI changes
and stats will all be set directly from the data table. So you don't
have to worry about going around making those changes. If you have any
doubts regarding the workflow, just let me know in the comments, and I'd
be happy to help.
Comments
Post a Comment