Time for action - exporting buildings to Unity 3D

  1. It's now time to export to Unity. First open Unity and check what you already have inside.
  2. In SketchUp, select the buildings you just inserted. Now, group them and label the group SU_Buildings.
  3. Follow the steps in Chapter 5, Game Levels in SketchUp, to export this group to your SketchUp4Games folder. Remember to select Export only current selection.
  4. When you switch to Unity, your buildings will load automatically, but they won't be in the right place yet.

    Tip

    Using temporary 3D Warehouse assets in your games

    Importing these buildings to Unity may take a long time if you used buildings from the 3D Warehouse. That's because people uploading buildings to 3D Warehouse aren't always thinking about low polygon modeling, using a single texture, or other game asset performance issues. Don't worry about this. Don't forget that at this stage it's all about getting a playable level into Unity so that you can test it and decide what artistic or gameplay decisions to take next. If and when you start to finalize your game, you will also wish to replace these assets with ones you made yourself or other people's you fixed up really well for game use (see Chapter 7,Quick Standard Assets).

  5. Open the Project tab, and click on OuterBuildings. Select the Generate Colliders check box and change Scale Factor to 1.
  6. Drag your new asset into the model window.
  7. Your buildings will appear somewhere in your game level, but not necessarily where you want them to be!
  8. Next, select the group and type in 0 in each of the x, y, and z dimension boxes. Hit Enter.
  9. Your buildings will move into place.
  10. Now, check that all textures have imported correctly. If you notice any see-through faces, such as in the next image, that will be because these are back faces in SketchUp (see Chapter 7, Quick Standard Assets). Go back into SketchUp and reverse these faces before continuing, and then re-import.
    Time for action - exporting buildings to Unity 3D
  11. In SketchUp, select all the fence components, group them, and import them into Unity (select "two-sided faces" in the Export options this time). Follow the steps above to resize and put them in the right place.
  12. Now, import one of each of your assets and place them somewhere in your SketchUp level, then export to Unity. You should have one each of the following:
    • Pallets
    • Oil drums
    • The wrench
    • Cars
    • Any additional street furniture you've modeled or imported
    • The main building
    • Import any furniture and other items for the inside of the building individually if the game requires them to move or be interacted with (for example, opening doors).
  13. In Unity, move the lights and pallets you placed there in Chapter 6, Importing to a professional game application: Unity 3D, to where you want them, now that you've designed your main building.
  14. You can copy your assets by selecting them and going to Edit ¦ Duplicate. Put plenty of barrels and pallets around the place. Use the Rotate button to make them look more randomly placed.

What just happened?

When you export a group of SketchUp objects, that group will also act as one group in Unity. This is fine for static elements such as buildings and fences, but you need something to move, such as a door opening and closing or a barrel rolling over when you kick it, it's best to import it individually. The reason you imported a single item instead of many of them (for example, in case of a barrel, you should have many of them scattered around) is that you can assign scripts and physical attributes to the single unit in Unity, and then copy that item around. Copying items within a game development environment such as Unity, rather than SketchUp, is much more memory-efficient because game engines can recognize when an object is just a copy of another. These are called Instances. This means that only one version of the object is loaded into the memory, and all other copies (instances) are not really there, but mirrors of the first one.

Rather, it's like putting up a few mirrors in front of you. You see yourself many times—but you don't need to eat any more. That's how you know these extra "YOUs" are just instances of you and not copies. If, however, you get downstairs tomorrow morning and all the Weetabix is gone, the people sitting at your breakfast table are definitely not instances. You should see a psychiatrist, or someone who can explain parallel universes to you. Or, maybe both.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.134.17