! ! DISCLAIMER ! !
This API is still in development and is not ready for production use. It may be filled with unknown issues or bugs. Additionally, code is subject to change.
This is a small and simple API which allows for quick and dirty random character profile generation in Unity. Users can define classes, species, traits, and attributes through a custom editor window. It uses a system of availability rules and trait negation to help control the randomization of new profiles.
- Configure character details such as:
- Attributes
- Traits
- Species
- Classes
- Custom editor window
- Super stable serializable data structure
- Custom availability rules and trait negation
- GUID based system
- Extendable C# API
- Light weight
- Editor uses C# Reflection due to Unity's horrible handling of complex object serialization
- This is more of a performance concern for editor serialization speed, it has no other negative implications
- Serialization works completely fine, no data is lost when saving or editing
- Dev-Heavy, a lot of custom code is needed to actually use the randomly generated characters
- Character leveling / experience is not covered in this API
- Character abilities are no longer supported (this may come back in the future)
- Complete documentation
- Improve extensibility
- Improve UI for character testing
- Improve custom editor window stability
- Settings
- C#
enum
andclass
generation tools
Push/pull requests are welcome but subject to code review!
This API is licensed under the MIT license. Consider supporting the developer(s) in your game's credits.
- Austin Renner (website)
- Create a new
GameObject
in the current scene and name it "CharacterProfileManager" - Add the
CharacterProfileManager
component - Use the Inspector or
Tools->Character Profile Manager
menu to open the editor window - Ensure that the
GameObject
from step 1 is assigned to theCharacterProfileManager
field in the editor window - Begin creating/editing content. Don't forget to save your work!
All tutorials assume you have the CPMAPI configuration window open.
Classes are professions or roles given to characters. They can be made exclusive or unavailable to one to many species and other classes.
- Select the "Classes" window mode
- Click the "Add New Class" button
- Give the class a name, icon, description, or availability rules
Species are the types of creatures that exist in the world that the character profile represents. They can have unique attributes, traits, classes, etc.
- Select the "Species" window mode
- Click the "Add New Species" button
- Give the species a name, icon, description, base attributes, or availability rules
Attributes are a major component to a character profile. They specify competency in certain aspects of the game. An example would be "Move Speed", "Accuracy", "Charisma", or "Arcane Power".
- Select the "Attributes" window mode
- Click the "Add New Attribute" button
- Give the attribute a name, icon, description, or availability rules
Traits are profile modifications which affect attributes or other gameplay mechanics. An example would be a trait called "Smart" which positively affects an attribute named "Intelligence". For more complicated effects and impacts on mechanics, custom developer work is required to recognize when a profile has a certain GUID.
- Select the "Traits" window mode
- Click the "Add New Trait" button
- Give the trait a name, icon, description, attribute effects, negations, or availability rules
These objects determine the actual effect a trait has on a character profile's attribute.
These objects help prevent the random trait assignment system from adding two traits to a character's profile which contradict one another. For example, a "Smart" trait positively effects an "Intelligence" attribute while a "Dumb" trait negatively effects the same attribute. It would be contradicting for a character profile to have both the "Smart" and "Dumb" trait. When configured, the "Smart" trait could have the "Dumb" trait listed as a negation which would ultimately prevent the two from both occurring on the same character profile.
Availability rules help restrict certain classes, traits, or attributes to either be exclusive to or unavailable to another species or class. For example, a class called "G'Hork" may be designed to only appear for a species called "Orc" and not a species called "Human". The class's availability rules can be set to ensure the class is "Exclusive To" the given species "Orc".
Name builders are object references that can be assigned to a species. They help "build a name" for the character given the implementation's rules. The CPMAPI comes with two by default which are accessible via the scene context menu.
- Create a new C# class and inherit from
CharacterNameBuilder
- Implement
string CreateRandomName()
which should return a randomly generated charater's name - Create an instance of the new type within the Unity Editor and assign it to the species of your choice
This name builder chooses a random name from a predetermined list.
using System.Collections.Generic;
using CharacterProfileManagement.Utility;
using UnityEngine;
namespace CharacterProfileManagement.NameBuilding
{
[CreateAssetMenu(menuName = "Custom Name Builder")]
public class CustomNameBuilder : CharacterNameBuilder
{
public List<string> names;
public override string CreateRandomName()
{
// the "Random()" function comes from a static extension in "CharacterProfileManagement.Utility"
return firstNames.Random();
}
}
}
The easiest way is to use the CharacterProfileManager
's non-static function. You are not limited to using this method, it just is the fastest/easiest to get things going.
var randomCharacter = CharacterProfileManager.Instance.RollNewCharacter();