In this tutorial, we will be adding a ranged weapon to the unit we created in the previous tutorial. Weapons allow units to auto-attack other units.

This tutorial will cover:

1. Creating A Missile Unit


Create a new unit named “Hero IceMage Weapon Missile” and set its Parent to "_CMissile. The names don’t really matter (except when creating a unit and unit actor—those names must match), but we use a general naming pattern that helps keep large projects organized.

https://user-images.githubusercontent.com/56179268/218136294-d90e8848-7227-402d-8f0d-22efc078156a.png

As with the hero, the actor for the projectile is automatically created. Set the actor’s Resource Type to “ParticleAnimation” and the Resource Name to “vfx_icemage_weapon_missile”.

https://user-images.githubusercontent.com/56179268/218137255-ccfd44ee-f08f-453a-aaa2-3f853dbbf5a7.png

2. Creating Effects


Enable the Effect filter and create a new effect. Name it “Hero IceMage Weapon Damage”. Set the Effect Type to “damage”, and the Damage Amount to “5”. You’ll notice there’s a Which Unit field that we’re leaving it set to the default value of “Target Unit”. This means that the effect is run on the target unit of the previous effect (or weapon/ability that creates this effect).

https://user-images.githubusercontent.com/56179268/218140445-823f5905-8230-45d1-be8c-6193c01f479d.png

Next create another new effect and name it “Hero IceMage Weapon Launch”. Make sure the Effect Type is set to “Launch Missile” (which is the default). Set the Missile Unit to the missile unit we created (Hero IceMage Weapon Missile). Set the Impact Effect as the damage effect we created (Hero IceMage Weapon Damage). Leave the rest as the default values.

Notice the Object Explorer. Our Weapon Missile unit and Weapon Damage effect are now both associated with our Weapon Launch effect. We made a connection between the two effects when we set them in the Field Editor. You can also see the connection in the Node Editor window.

https://user-images.githubusercontent.com/56179268/218143394-9a6b2206-197a-4463-b5fb-d50a19467e4a.png

3. Creating A Mover


Now enable the Mover filter (or “All”) and create a new mover. (Alternatively, right-click in the node editor and select “Add New Object”) As the name implies, Movers help determine how other objects/units move.

This time, let’s use a template by setting the Template field to “Standard Ballistic Missile”. Using a template is similar to using a Parent field, except the data is only copied once (when the new object is created), and not updated if the parent value changes. Let’s name it “Hero IceMage Weapon Missile” since this mover will determine how that missile moves.