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.

Before After

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.

Like this article?

Share on facebook
Share on Facebook
Share on twitter
Share on Twitter
Share on linkedin
Share on Linkdin
Share on pinterest
Share on Pinterest
Adam

Adam

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.

Leave a comment

POLYEnvironment

Collection of a cartoon-style environment and props models with 40+ prefabs. Super lightweight because all prefabs are using material colors only, and the average polycount is way below 1000 vertices.

View Asset

Dark Fantasy Kit

Dark Fantasy Kit is a modular 3D PBR environment package which contains 400+ prefabs to create a residence of a villain or evil mastermind of your RPG game with a First Person, Third Person or a Top-Down view. Works with Unity versions from 5.6 to 2018.

View Asset