Penguin ARPG Toolkit

What is PAT

Penguin ARPG ToolKit is an Unity Package for building combat system. I am the project raiser and lead programmer for the Toolkit. While the package itself is working now, we will still add some new features to it as we use the Toolkit for our own projects.

Cool Feature I did

State Modifier: the root of PAT

In PAT, the unit of state machine are those Action State. However, you don’t need to always write a new inheritor of Action State Base Class to build an Action. Instead, you decorate the behavior of this state with state modifiers

State Modifiers are easy inheritable classes in PAT. In most cases, you just need to either override the validation part to determine if this Action is legal, or override the begin/end event to do some behavior. User don’t need to take care of the timing, it will be handled properly by the system. You can bind it with Animation Event, or manually set a duration. And this design actually enabled the next feature in PAT


Action State Timeline: what I used most in production

Having too many mono-behaviors on inspector is not very maintainable. More importantly, you can not visualize the action in your mind reading them. Thus we used custom editor to visualize state modifiers into grids on a timeline. The start and end point of those grid is 1:1 represented in the graph, even if you pick to link to animation event, it will grab the animation clip info and scale it with your montage speed modification to display it at the right position.

And of course, as we have the timeline, and we have each state modifier as object, we managed to make this action state timeline preview-able in editor mode, making particle system and sound sync with animation, which is something not possible in animation preview. Other feature like montage speed, root motion multiplier, extra movement are also previewable.

And as you can see, user can easily modify the timing attribute by drag and drop in the timeline as well. In short term, we kind of re-invented unity’s timeline system in PAT. One thing I did bad is that I didn’t make the timeline behavior controlled by state modifier themselves, instead I hard coded them in the fron-end code cause I did this feature over one week end. Next time, I might try to see if I can build the combat system with Unity’s official timeline and playable feature.


Dynamic State Transition

Instead of having a traditional state machine with fixed transitions, I was inspired by Unreal’s GAS and thus build this dynamic transitioning system. PAT-Character will store gameplay tag. Those tags are collected from current action state and also effects which I’ll talk about later. Anyway, you can easily build are flexible state machine with tags and conditions if you organize the logic well. So your character can perform some combo while changing into another weapon. And of course you can add some exceptional conditions by manually linking two states. We are still working on how to visualize this one

Game Play Tag

Also inspired by Unreal GAS, we have gameplay tags that nested in folders which can be used for many different scenarios.

But our gameplay are enums, not string. How do we make it into folders?

We add a scriptable object called game play tag helper, so that when you are using gameplay tag in inspector, the editor script will present you the tags in how they present in the helper. Meanwhile, the data is still stored in enum and there’s no any difference if you want to use those tag directly in script.


Effect: how characters actually communicate with each other

Effect are kind of a data container for PAT Character to communicate with each other. You can also add behavior to it to achieve some thing as it works parallels with Action State. Effect itself simply have some tags. You can control the behavior by adding components on it, similar to action state.

Since many important and basic things are using effect in PAT (damage, walk speed) and we don’t want our user always need to choose between creating a new scriptable object/write many scripts, we add a class called effect factory which is a static one that gives you many well structured effects as you input parameters.

Attribute Law: how numbers are calculated

Effect are in charge of dealing damage. But what about crtical rate? What about defense? We can definitely simply override the health class, but what if we want to make something cool?

And here comes the globale attribute law. Before many effect mod the attribute value, those scriptable object will pre-process the value base on their own rule.

For example, in this critical determine law, you set the resource tag to health to health attribute, you set it to negative to ensure it’s damage. And then you set the tag to add if legal

Then in this scriptable object, you check if there is the tag you are looking for, then you multiply the value of this damage by the attribute CATK of the damager.


Take away

  • People want to one click create a new move/character, even if it is not best config, still better than not having it

  • PAT is making easy things harder, hard things easier

  • There will be no one thing for all solution

  • Usability and Extensibility always fight each other

  • Sometimes users don’t need that many customization

  • You can, and shall always iterate your code. But you also need to take care of every past

Previous
Previous

Fire Stolen

Next
Next

Moon Rescue