This is a premium alert message you can set from Layout! Get Now!

How to design a simple level using Probuilder in Unity

0

Often when you start developing a game in Unity, you want a trimmed-down version of an environment where you can move your characters around. ProBuilder allows you to quickly create and prototype 3D levels, as well as create basic 3D models without leaving Unity.

In this article, you will learn how to design a simple level in Unity using ProBuilder.

This is a sneak preview of our final result.👇

Final Result Of Unity App With ProBuilder

Unity project setup

If you haven’t done so already, create a new Unity 3D project and name it “Hello ProBuilder.”

You can do so by launching Unity Hub on your computer and clicking New Project.

Launch New Project With Unity

After clicking on New Project, the window below pops up. To ensure that we are creating a 3D project, complete the following steps:

  1. Select 3D from the templates
  2. Update the Project Name from “My Project” to “Hello ProBuilder”
  3. Click the Create Project button

Create 3D Project

The project will take a few minutes to open up in Unity.

Keep the project open, and let’s work on integrating ProBuilder.

Setting up ProBuilder with Unity

In this step, you will add the ProBuilder package to the Hello ProBuilder project in Unity.

To start, download the ProBuilder package. To do so, go to Window > Package Manager. Switch Packages to Unity Registry. Search for ProBuilder and click Install.

Install ProBuilder

To verify if ProBuilder is installed successfully, go to the Project panel on the bottom left-hand side of the Unity editor. Expand Packages. If you see ProBuilder on the list, you know that ProBuilder was successfully installed.

Verify That ProBuilder Was Installed

In the top toolbar, click Tools > ProBuilder > ProBuilder Window. Dock the ProBuilder window wherever you want. I like to dock it just next to the Hierarchy panel.

Dock The ProBuilder Window

Great. You are all set to explore the different features of ProBuilder.

Using shapes in ProBuilder

Let’s begin with New Shape.

Explore New Shape Feature In ProBuilder

The New Shape feature allows you to create 12 different primitive shapes:

  1. Arch
  2. Cone
  3. Cube
  4. Cylinder
  5. Door
  6. Pipe
  7. Plane
  8. Prism
  9. Sphere
  10. Sprite
  11. Stairs
  12. Torus

Let’s begin with bringing a cube into our scene. To do so, click New Shape. You will see a Create Shape panel open in the right-hand corner of your Scene panel. Select the cube icon. Hold left click and drag the shape out like this:

Creating A Cube In ProBuilder

Set the cube size to 1 unit across X, Y, and Z.

Note: If you go back to the Hierarchy panel, you will see that the new shape (i.e., the cube) is a GameObject.

Selection modes in Unity

The four buttons at the top of the Scene panel are used to switch between the following four selection modes:

Selection Modes In Unity

 

  1. Object selection
    Object Selection Mode In Unity
  2. Vertex selection
    Vertex Selection Mode In Unity
  3. Edge selection
    Edge Selection Mode In Unity
  4. Face selection
    Face Selection Mode In Unity

This level of manipulation is not possible with the standard 3D objects in Unity. In other words, you can create a cube GameObject (right click > 3D Object > Cube), but you cannot control its vertices, edges, or faces within Unity. This is why creating a cube (or any other shape) with ProBuilder is a better alternative.

There are certain operations that you can perform on your 3D object to help you create the shape that you want to achieve. The three operations that you will perform in this article are:

  1. Flipping normals
  2. Extrusion
  3. Bevel

Create a room in Unity using ProBuilder

Let’s begin by creating the boundaries of a room. It’s easier than you think.

  1. Create a cube (using ProBuilder and not Unity’s standard 3D object)
  2. Keep the dimensions 5 x 2 x 5. This is what you get👇
    Create A Cube Room In ProBuilder
  3. Make sure you are in the Object selection mode. Select the cube. Click Flip Normals from the ProBuilder panel, and you get a room. Simple, right?
    Flip Normals To Create Room

Now let’s add stairs inside this room.

First, scale the room up 10x by going to the Hierarchy panel > Select Cube. From the Inspector panel on the right-hand side, ensure you enable constrained proportions for the Scale Property. Then put 10 as the scale for X, Y, and Z.

Next, switch to the ProBuilder panel, click New Shape, then click the Stairs icon from the Create Shape panel. Left click on the scene and hold. Drag to stretch along the X and Z axis. Release the left click. Move the cursor along the +ve Y axis to set the height of the stair. Do a left click and that’s it. You have created a stairway.

Create Stairs With ProBuilder

Pro tip: Make sure that you do not select any other object instantly after creating a new shape. Otherwise, you won’t be able to change the stairs from their configuration window (or Create Shape window). You will have to delete the existing stair and create another one. This might be difficult during the first few attempts, but you will get the hang of it with some practice. My advice here would be to go slow at first. Gradually, you will become faster.

Play around with the different Stairs Settings for the stairs here and observe the changes.

Adjusting Stair Settings With ProBuilder

I have kept these settings for the stairs:

Author's Saved Settings For Stairs In ProBuilder

Ignore the values under Shape Properties. You might have different values depending on the ‌look you are going for.

This is what my room looks like:

Example Of ProBuilder Room With Stairs

Now, let’s say that if there was a character going up the stairs, there should be some kind of platform at the end of the stairs to walk around; otherwise, the character would fall down. Let’s build that little platform by using extrusion.

  1. Switch to Face Selection mode and select the end face of the stairs:Face Selection Of ProBuilder Stairs
  2. Hold Shift and drag the selected face forward. This step is called extrusion. You just extruded one face of the stairs.
    Extrusion Tool In ProBuilder
  3. Now, increase the length of the platform horizontally, like this:
    Editing Stair Thickness In Unity With ProBuilder

You can increase the thickness of the platform as much as you want. Feel free to experiment. Think of this as “artistic freedom.”

Let’s see how to bevel now. Beveling can be performed on edges and faces. Technically, if you bevel a face, then all the edges that make up that face are going to become beveled, so it is still only being applied to edges. This is what beveling looks like — the sharp edges of the selected face become rounded (beveled).

Beveling Stairs

To perform beveling, select a face or an edge and click the Bevel button from the ProBuilder panel.

If you click on the + icon on the right side of the Bevel button, you can also adjust the amount of beveling.

Try the other operations, including:

  1. Subdivide
  2. Merge
  3. Delete

See what environment you can come up with.

Bring a character into your Unity environment

Download this free Starter Assets pack from Unity. If you haven’t downloaded it before, it will say “Add to my Assets.” Click that and then click Open in Unity.

Asset Starter Pack To Build A Character

The Package Manager will open automatically in your Unity project. Then, click the Download button in the bottom right-hand corner.

Downloading Third Person Character Pack

Next, click Import.

Importing Character Pack

Delete the Main Camera from the scene.

Deleting Main Camera

Then go to the Assets panel > Starter Assets > ThirdPersonController > Prefabs.

Selecting Prefabs From Assets Panel

Drag the NestedParentArmature_Unpack prefab into the scene and position it inside the room anywhere you like.

NestedParentArmatureUnpack Prefab

Increase the size of the prefab by changing the scale by 5 (or whatever looks good to you).

Adjusting Prefab Size

From the Hierarchy panel > NestedParentArmature_Unpack > select PlayerArmature. In the Inspector panel, locate the “Third Person Controller” script and change the following values:

  1. Move Speed = 15 (as per your liking)
  2. Sprint Speed = 25 (as per your liking)

Adjusting Move And Sprint Speed For Character

Click Play to let your character walk around in the environment. Use the W, A, S, and D keys to move around. Hit Space to jump and use the mouse to look around.

Final Result Of Unity App With ProBuilder

Conclusion

Awesome! You just created a level in Unity with ProBuilder.

If you face any issues or need some help, please ping me on Twitter or LinkedIn, and check out my Gumroad page or YouTube channel if you’re looking for more Unity tutorials and resources.

Extra resources

The post How to design a simple level using Probuilder in Unity appeared first on LogRocket Blog.



from LogRocket Blog https://ift.tt/3rhv1qy
Gain $200 in a week
via Read more

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Post a Comment

Search This Blog

To Top