Attack Profiles allow you to setup attack styles based on the weapon you’re equipping. These attack styles determine how your character attacks.
A while back I introduces attack styles with the Sword & Shield Motion Pack. This was cool because it allow you to setup different attack animations, attack zones, and damage amounts. So, instead of your character just swinging a sword one way, you could have dozens of different attack styles.
When your game allows for only one melee weapon, this works great. However, if you’re using the Basic Melee Attack motion to support any kind of weapon have a list of 100s of attack styles becomes unwieldy.
TeagansDad from the forums had a great idea. Instead, we could attach the attack styles to the weapons themselves. So, when a weapon is equipped we clear the current list of attack styles and refresh it with those styles that are associated with the weapon in-hand.
That weapon-centric list of attack styles is know as the Attack Profile.
Basic Attack Profiles
If we look at one of the sword prefabs, you’ll see it includes a “Basic Attack Profiles” component. Think of this as a collection of attack profiles that the weapon uses.
We do that as a list of ScriptableObjects because it allows us to share attack profiles across multiple weapons.
The attack profile itself is a ScriptableObject. That means it’s a data container that doesn’t really live in the scene. It can live in any scene and can be re-used as you saw above.
The attack profile contains data that transferred over to the character when the weapon is equipped. So, it doesn’t have any action itself other than holding data.
As you can see, it looks pretty similar to the Basic Melee Attack’s attack styles. That’s because the attack styles listed here are what get moved to the Basic Melee Attack motion.
Creating Attack Profiles
To create your own attack profile, just select Assets | Create | ootii | Combat | Attack Profile from the Unity menu.
Since it’s a ScriptableObject, it will be created in a Project folder and not in the scene. You can edit the attack profile as needed.
Then, do the following:
- On your weapon prefab, add a Basic Attack Profile component
- In the Basic Attack Profile component, add a new Attack Profile entry
- Drag your newly created attack profile to this entry
That’s all you need to do to configure the weapon prefab.
Each character that will be using a weapon with Attack Profiles will also need the Basic Attack Profile Reactor added to its Actor Core component (the default settings on this reactor shouldn’t need to be changed).
Now, when your character equips the weapon, attack styles will change to reflect what is in your attack profile.
Attack profiles only work with melee weapons. We may expand this in the future, but for now they are for the Basic Melee Attack motion only.