Book Cluster Generator Script

They said a good programmer is lazy. Well, I hope this is true because I was super lazy on the other day. I literally wrote a script in several hours instead of doing 10 minutes of work by putting prefabs together.

This sounds silly, right? Maybe it is, but I enjoyed working on this small script and trying to remember to the trigonometry from high-school. Let me introduce the weird and questionably useful result of my lazy-work: the Book Pile/Cluster Generator.

On the two screenshots below you can see, the very different result of a single click on a button.

So how did I end up to make something like this? Currently, we are working on the first update for the Dark Fantasy Kit. While Dotti is still modeling and texturing, my job is to test the models and create prefabs from it. We already added 100+ new prefabs, and there were multiple iterations, it’s quite a work. While I love doing this, it started to become too repetitive.

At the time I had to create a few book piles and clusters from the books she made, I just can’t start it. I decided to let rest the left side of my brain, and work with the right side, and the script was born.

How to use it?

  • Download and import it to your project.
  • Create a new prefab and add the script to it.
  • Select the type from the general settings, and add your books to the list.
  • Set the Book Parameters section. If you are using our books from PBR Alchemy Lab or from the Dark Fantasy Kit, you can leave it as it is.
  • Tweak the settings for the right type.
  • Click on the Generate button.

Pile Settings

  • Book Count: the number of books in the pile.
  • Rotation Random: determines how much rotation is applied to the books. 0 means zero rotation, the books will lay on each other in perfect order. 1 means the books are rotated very differently.

Cluster Settings

  • Cluster Width: instead of giving the book count in case of a cluster you set the width of the book cluster.
  • Slanted Random: how many books should be slanted.
  • Slanted Max Angle: the maximum angle by with the books are slanted.
  • Z Pos Random: determines the random offset applied to the book position z axis.
  • Show Gizmo: for debuging purposes.

5+1 Free Asset for Unity that you will use all the time

I use several assets for my work as a freelancer and asset store publisher. Some of them are paid assets, others are free.

There are a handful of assets that I’m using in almost every project. I would love to share them with you, because these are free, and improved my workflow a lot!

Before we jump in, click on the subscribe button! I’ll post similar articles to this in the close future. It would be a shame to miss it! 🙂

1. Cinemachine

Cinemachine is unified procedural camera system for in-game cameras, cinematics and cutscenes, film pre-visualization and virtual cinematography eSports solutions. Says the description in the Asset Store but why do you need this little asset gem?

If you have already worked with a camera in your project, you might meet with these problems:

  • Setting up and controlling the TPS camera in the right way could be a pain to code.
  • Multiple cameras on the scene for cutscenes, testing or any other purpose can take out of the control of your game camera.
  • If you have multiple cameras on your scene, multiple Audio Listener would be the problem. Removing them are not always a solution.

Fortunately, this asset provides a smart solution for the latest two: virtual cameras. Virtual cameras are dummy objects with camera settings on them. Cinemachine will take the settings from this dummy object that is active, and update the real camera with it. Therefore you will need only one Camera in your scene.

You can use as many virtual cameras in your scene as you want. Cinemachine can switch between them in multiple ways.

It has a lot’s of features that will help you in your development: the Smooth Follow and the Free Look camera options are great for TPS games, and you can create them literally with a single click! Also, have a built-in solution for wall avoidance.

For more information, visit the Tutorials and the Documentation.

If you are using Unity version 2018 or higher, you can import Cinemachine from the Package Manager. If you are using Unity version 2017, download it from the Asset Store!

2. Post-Process Stack

Post-processing is the process of applying full-screen filters and effects to a camera’s image buffer before it is displayed to screen. It can drastically improve the visuals of your product with little setup time.

You can use post-processing effects to simulate physical camera and film properties; for example; Bloom, Depth of Field, Chromatic Aberration or Color Grading.

For better understanding let me show you a before-after image from our Dark Fantasy Kit.

I used a very subtle Post-Process here because I didn’t want to hide the details of our models, just improve the colors and give the full scene little more depth.

Post Process is a powerful tool for your game and very easy to use!

If you are using Unity version 2018 or higher, you can import Cinemachine from the Package Manager. If you are using Unity version 5.5 or higher, download it from the Asset Store!

3. Screenshotter

When you finished your beautiful scene, you want to share with others. You could start the game, press Print Screen, and paste it to Gimp or Photoshop and cut the taskbar from the bottom. I did this, and I’m not proud of it. It looked easy at that time, and I didn’t really consider the fact, it will result in a very low-quality image.

When I realized this mistake, I wrote a small code to be able to take a screenshot in a resolution I want. Lucky for you, I share this little script, so you can download, and import it to your project and add it to the main camera.

Download

4. Unity Recorder

Presentation of your work in the right way is essential. My Screenshotter script helps you make a high-res screenshot, but if you want to make a good quality video from your game, you should take a look at this asset.

Unity Recorder is an Editor-only tool, so you can’t use it in a built version of your game. You can create 4K, 60fps videos with this asset. It’s memory intensive, so it’s best to create videos that don’t require user interaction, like the fly through video, I made for the Dark Fantasy Kit.

Download from the Asset Store!

5. Mixamo Animations

This isn’t directly connected to Unity, but I found it extremely useful. They have thousands of motion captured humanoid animations for free to download. The quality of these animations is in a wide range of variety.

Perfect for prototyping and for placeholder animations. Some of them are acceptable as final animations too.

Mixamo Animations

This video should help you how to download and import the animations from Mixamo to Unity.

+1. Sonniss 30GB Sound Library

I already wrote about the impressive amount of sound effects that Sonniss published. You can use this collection for free even in commercial projects.

What do you think about this assets?

Did you already know them? Do you have any asset that is free and you are using it a lot in your projects? Tell me in the comment section below!

High-Resolution Screenshot

With this little script, you can capture screenshot in any resolution.

Res Width, Res Height
The resolution width and height of the captured screenshot. You can set any number here.

Take Screenshot Key
If this specific key is pressed, the script captures the screen.

Save Path
Absolute path of the folder where the script saves the screenshot. The absolute path looks similar to this: E:\Projects\_ASSET\Dark Fantasy Kit\Screenshots

What do you think about this little script? Shoot a comment and tell me!

170+ Free PBR Materials

Recently encountered with Struffel Production on Patreon. He is creating PBR materials. The best part is that you can download these for free from his website. There are an insane amount of PBR mats: 170+ and its growing.

All of the materials on the website are under the CC0 License. This means you can use them in whatever project you want to use (even redistribute with your model), and you don’t have to give credit to the author.

The website and the work are funded through Patreon

Hero Fantasy Pack Vol 1 (Asset Review)

  • Publisher: Kristian Grundström
  • Genre: Fantasy Music
  • Asset Store Rating: - star, 2 review (Personal Rating: 5 stars)
  • Asset Store Link

This is an epic medieval / fantasy music. The package contains 4 themes, all have a loopable version, and the package contains multiple variations of each theme.

[Full Disclosure: as an affiliate, I receive compensation if you purchase through the links on this page]

Content Quality

The asset contains four themes each of the themes has parts with different dynamics and intensity, and each part has multiple variations.

The music was designed to work well with third-party audio solutions like FMOD or Wwise. These middlewares are great tools if you want to achieve Adaptive music (also known as Dynamic Music) in your game.

The four themes are:

  • Embracing Fate: a highly dynamic orchestral. 
  • Disillusional: more emotional and cinematic feel.
  • In the Mids of Ruins: or as I called it the Dwarf theme. This theme has the most parts from a calm ambient to a very high-intensity one.
  • What to Come: more of a menu or a cutscene music. However one of the stinger resembles of the music in Witcher III. Not sure if it’s intentional or not, but I really like it.
  • Third party audio solution support.
  • Multiple variety to prevent monotonity

Adaptive Music with Unity

FMOD and Wwise are awesome tools, but if you don’t want to learn a third-party software, you can still achieve Adaptive Music with Unity itself.

Unity created a great tutorial for this: Adding Music to Your Game

And depending on my experiences this asset works very well with the tutorial! The publisher also noted the BPM value of each theme that is super helpful!

Support & Updates

The asset was published on Feb 2, 2018. There was another update in June. This is quite a fresh asset. And according to the publisher comment, more music will come!

Personal Experience

I never before worked with music yet. So I had to learn a little about it before I made this review. The tutorial I linked above helped me a lot, and after a few hours of experimenting I came up something really cool in combat – out-combat effect.

Final Conclusion

This asset is one of my WELL SPENT MONEY recommendations.

This asset is very well made. If you need a fantasy music for your game you should consider buying this one.

About the Author

Adam Galla

Adam is the founder and developer of the Runemark Studio. He graduated with BSC  degree in Software Engineering in 2013.

He is working as a freelancer game developer and asset store publisher since 2014.

Animator Parameter Name Field

Sometimes we want to refer to an Animator Parameter from the inspector by name. In this case, there is a chance we don’t remember the names of the animator parameters. This doesn’t look like a big deal, but it’s proven that only a few clicks can increase the work time by a lot if these few clicks are frequent.

The following code improves the single text field with a drop-down button. This will show you all the parameters of the Animator on this object. You can also filter the list by animator parameter type.
Let’s get started!

Animator Parameter Attribute

First, we need to create a new Attribute. We need two variables for this class. A Type value that will be an AnimatorControllerParameterType and the other variable will be the FilterByType boolean. This will tell us whether or not we want to filter our parameter names based on their types.

public class AnimatorParameterAttribute : PropertyAttribute
{
   // Determines whether or not we are using Type to filter the list.
   public bool FilterByType;

   // We will only show parameters of this type.
   public AnimatorControllerParameterType Type;

   public AnimatorParameterAttribute() { }
   public AnimatorParameterAttribute(AnimatorControllerParameterType type)
   {
      FilterByType = true;
      Type = type;
   }
}

Animator Parameter Drawer

The next step is to create our Property Drawer class. This will be more complex, but the basic idea is this: 

We will grab the property (or variable if you wish) that is marked with the previously created Animator Parameter Attribute. This will give us a SerializedProperty type of variable.

From this SerializedProperty object we can reach our actual script (.targetObject) and from there the GameObject it’s attached to, finally, the Animator that is on this GameObject.

If we have the Animator as a reference, we can go through its parameters and collect all the names we want (filtered or not by types).

Lastly, we draw a PropertyField for our string variable (this will be a simple TextField) and a little button for the dropdown list.

[CustomPropertyDrawer(typeof(AnimatorParameterAttribute))]
public class AnimatorParameterDrawer : PropertyDrawer
{
   GUIStyle _popupStyle;

   int _index;
   List<string> _names = new List<string>();
 
   public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
   {
      // Reset Names
      _names.Clear();
      _index = -1;

      // Get the Attribute
      AnimatorParameterAttribute attr = attribute as AnimatorParameterAttribute;

      // Grab the animator from the property
      var go = (property.serializedObject.targetObject as MonoBehaviour).gameObject;
      Animator a = go.GetComponent<Animator>();
      if (a != null)
      { 
         a.Rebind();

         // Iterate through the parameters
         int cnt = -1;
         foreach (var p in a.parameters)
         {
            // If the attribute is not filtered, or it has the same type
            if (!attr.FilterByType || attr.Type == p.type)
            {
               _names.Add(p.name);
               cnt++;
               if (p.name == property.stringValue)
                  _index = cnt;
            }
         } 
      }
 
      // Init popupstyle
      if (_popupStyle == null)
      {
         _popupStyle = new GUIStyle(GUI.skin.GetStyle("PaneOptions"));
         _popupStyle.imagePosition = ImagePosition.ImageOnly;
      }
      
      // Draw the property
      label = EditorGUI.BeginProperty(position, label, property);
      position = EditorGUI.PrefixLabel(position, label);

      EditorGUI.BeginChangeCheck();
      int indent = EditorGUI.indentLevel;
      EditorGUI.indentLevel = 0;

      if (_names.Count == 0)
      {
         GUI.Label(position, "No Animator is attached or it has no parameters");
      }
      else
      { 
         // Calculate rect for configuration button
         Rect buttonRect = new Rect(position);
         buttonRect.yMin += _popupStyle.margin.top;
         buttonRect.width = _popupStyle.fixedWidth + _popupStyle.margin.right;
         position.xMin = buttonRect.xMax;

         // Show a simple text field
         EditorGUI.PropertyField(position, property, GUIContent.none);
 
         // Draw a dropdown button for selecting the parameter name.
         int result = EditorGUI.Popup(buttonRect, _index, _names.ToArray(), _popupStyle);
         if (_index != result && result >= 0 && result < _names.Count)
         {
            Debug.Log(_index);
            _index = result;
            property.stringValue = _names[_index];
         } 
      }

      if (EditorGUI.EndChangeCheck())
         property.serializedObject.ApplyModifiedProperties();

      EditorGUI.indentLevel = indent;
      EditorGUI.EndProperty(); 
   }
}

Using this Attribute

Once you created these two classes, you can start to use your new Attribute. Important to note the Attribute only works with string variables. 

This is how you use it:

[AnimatorParameter] 
public string ParameterName;

This is a basic usage, the dropdown will contain every parameter name you have in the Animator that is on this GameObject. However, you can define a type to show only those parameters that have the given type. 

You can do it this way:

[AnimatorParameter(AnimatorControllerParameterType.Float)] 
public string ParameterName;

You can use the following types:

  • AnimatorControllerParameterType.Float
  • AnimatorControllerParameterType.Int
  • AnimatorControllerParameterType.Bool
  • AnimatorControllerParameterType.Trigger

30GB+ High Quality Sound Effects for FREE

SONNISS.COM giving away more than 30GB of royalty-free and commercially useable high-quality sound effects as a celebration of GDC 2018.

The package contains about 1000 audio files in a wide range of topics: magic, door opening, human voices, lots of cars…etc. You can check the complete tracklist HERE.

About Sonniss.com

Sonniss was launched in 2014, nowadays they have more than 300.000 sound effects from city ambiance to futuristic weapons. All of them are high-quality, and the company has a strict quality control procedure to assure it stays that way.

Their sounds have been used in Emmy-award winning films, world-renowned TV shows, high-budget AAA games, indie productions, and popular apps.