Setting up the Weapon Collision Component

Setting up the Weapon Collision Component

Now that the Weapon Collision Component has been applied to your AI's weapon object, you will need to adjust its size.

Note: If you have not already applied the Weapon Collision Component to your AI's weapon object, please see the Applying the Weapon Collision Component section.

With the weapon's "Edit Collider" enabled, adjust the size of the collider to fit the area of your AI's weapon you'd like to cause damage.

Next, open the Animation Viewer through your AI's Animation Profile. This will open the Animation Viewer and allow you to view your AI's animations within the scene view. Select one of your AI's attack animations through the Current Animation pulldown. Next, set the Event Type to Enable Weapon Type 1 Collider (or Type 2 depending on what weapon type your AI is using).

Note: See the Opening Animation Viewer section for a quick guide for opening the for your AI.

Find the frame you would like the weapon's collider to start being enabled. When you have found it, press the event button with the + mark. This will automatically add an Animation Event to your AI's animation to enable the weapon collider.

You will need to assign your AI's weapon's name to the String parameter. This allows the event to know which weapon to enable.

Next, do the same thing, but this time, use the DisableWeaponCollider Animation Event and find the frame you'd like the weapon collider to be disabled.

Once you are finished, press the Apply Changes to save the Animation Events that were created.

Note: Now that the needed Animation Events have been set up, there's still one more step below.

If you haven't already done so, you will need to add the Items Component to your AI. You can do this by searching for the EmeraldItems script and dragging it onto your AI.

Next, open the Weapon Settings foldout and assign your AI's weapon to the Held slot. This should be the same weapon that you assigned in the Animation Event above.

Test your AI against one of the included targets to ensure everything is working correctly and that the target is properly receiving damage. Keep in kind that this requires the weapon to physically hit a target. If an AI's weapon collider is unable to hit their target, you can adjust the size of the collider as needed.

Note: You can watch the collider during runtime within the scene view and with Unity's Gizmos enabled. However, this will only work if the AI is selected.

Last updated

Was this helpful?