Level-Creation using UUniCG, Blender and SketchUp

From Unify Community Wiki
Jump to: navigation, search

Contents

Introduction

On this page I will teach you how to use UUniCG to create entire levels in external applications in a more comfortable fashion. It should be noted that even though this tutorial is meant for Blender and SketchUp you should be able to apply the principles to any 3d modeling application.

Before starting it's recommended to read Mesh2Collider and UUniCG. Know your tools.

We will create a simple room that has some details you wouldn't want to generate full-detail mesh-colliders for. On top of that we will add an item that has a trigger that's larger than the item itself so the player doesn't have to look at it with perfect accuracy.

I'll say this only once: This is not a beginner tutorial as it's expected that you know your way around Blender and SketchUp already. This is merely a tutorial to show you how to integrate UUniCG into your workflow with minimal friction.

Preparation

Before we can start we need to do some preparations. Make sure you have everything set up before continuing.

Preparation 1: The setup

  • Create a folder called "Editor" in your Assets folder and place the UUniCG script inside
  • (SketchUp & Blender only) Download, save or save the following script in your favorites: Remove all doubles
  • Create your preferred folder-structure so your files don't mix up all over the place

Preparation 2: The plan

  • Download the plans I have drawn. We don't want to waste time thinking what to create, but solely focus on the how

File:UUniCG Tut Plan.zip (Please note: We're using metric units here)

Preparation 3: SketchUp

  • Multiple monitors: Open SketchUp and place the "Entity Info" and "Layers" windows that can be accessed through "Window" at a separate screen
  • Single monitor: Define shortcuts for them in the "Window/Preferences/Shortcuts" menu
  • Create two layers: "Geom" and "Col" (avoid using the default layer called "Layer0"*)

*The reason for this is that the layer system in SketchUp is a mess. The edges and faces an object is made of can be in a different layer than the object itself. That means that if you'll want to move something to a different layer later on, you'll have to select object, move it to the layer, edit the object, select all the child-objects, move them to the layer, edit all the child-objects individually and repeat this process till you moved each and every egde/face.

In other words: Make sure you create the objects in the right layer from the beginning.

If you work with multiple layers already, create two of these layers for each one. If you worked with, let's say three layers (structures, details, vegetation), you'll create six layers (Geom_structures, Col_structures, Geom_details, Col_details,...).

Besides that: Do not work with "Components" in SketchUp, since (as of writing) there seems to be issues importing them into Blender. Work with "Groups" instead. If you do need to work with them and encounter problems, turn them into groups before exporting.

Step 1: Main geometry (SketchUp)

Your geometry should look like this now.

The first thing to do is creating the visible geometry. Select the "Geom" layer and start modeling. The actual part of this tutorial starts after you've done this.

Other than repeating that you should make sure all the objects were created while the "Geom" layer was selected, there's not much to say here. We're working on a very simple model here after all.


However, we can think about the colliders already. Other than the door, everything can be broken down into boxes. So we could create most of colliders out of efficient box-colliders instead of letting Unity generate slow mesh-colliders. Detailled stuff like the door's handle and hinges, can be either ignored or exceptions to this.




Step 2: Collision geometry (SketchUp):

Finished collision geometry. Note the simplified door model.

Now we can start modeling the colision mesh.

We start with the floor. Select the "Col" layer, create a box with the same size and group the edges/faces. Name the group "floor_--B". Additionally you can reverse the faces since the backsides aren't rendered in Unity and the preview will look cleaner. This is optional though.

Rebuild the entire previously created geometry using as many primitive shapes as possible.

Note:
In future versions of UUniCG it will be possible to embed more complex instructions in the name. As such you won't be required to create the entire mesh again. Primitives in the ''"Geom"'' layer could have their mesh renderers preserved and you'll only have to focus on the objects where the visible geometry differs from the colliders.

Step 3: Exporting

SketchUp to Blender

  • Enable all the layers
  • (Optional:) Check if everything is in place. We don't want any misalignments
  • Use the "File/Export/3D Model" option and navigate to wherever you want to export the model
  • Make sure that you're exporting a COLLADA file and that everything is unchecked under "Options..." (a possible exception is "Triangulate All Faces")
  • Export the model

Work in Blender

  • Import the just created COLLADA file
  • (Optional: If something is missing try using the "Triangulare All Faces" option, Blender's COLLADA importer really could be better)
  • Since we don't need the Timeline we can replace it with the Python-Console
  • In Object Mode select all and paste the python script from earlier there
  • After executing it you should be notified about how many vertices have been removed
Note:
If you followed my tip to invert the collision mesh's normals, you'll need to remove/comment line 11 out. Otherwise the normals will be "fixed".

Additional steps in Blender

Depending on what you're modeling there's a few things you might want to do. Whether you want continue working on the model, unwrap or animate it or do something else.

  • Recreating the layers like in SketchUp is advised. Move the collision meshes in their own layer so you can see the model itself clearly
  • For animating the model it is important that the parenting hierarchy is correct
  • When you worked with Components in SketchUp, it is possible that not everything will export into Unity. You'll get notifications if that happens though

Blender to Unity

  • In Object-Mode use the Export FBX option and navigate to the folder you want your model to be exported to
  • Make sure that the Scale is set to 1.0 and "Z Forward" is selected

Step 3: Generating the colliders

The finished level.

If everything worked out, you should have a model containing meshes for rendering and collision.

When importing, use the usual settings. Make sure that the Scale Factor is set to 1 and that you neither generate colliders nor calculate new normals. (The latter one only applies to whoever used flipped normals for the collision meshes) Since we have no animations in this tutorial, we can set "Rig/Animation Type" to None too.

  • Place the imported model somewhere in your scene. (I place it at 0,0,0 since the model contains my entire scene)
  • Select the GameObject in the hierarchy
  • Open UUniCG ("Window/Collider Generation")
  • For this tutorial we check every option


Congratulations! You should be looking at a level created in an external editor with efficient colliders now. The files I created during the tutorial can be downloaded here: File:UUniCG Tutorial Files.zip

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Tools