Building a Castle in a Unity VR Game

Do you want to make a castle that players can enter in your virtual reality game? Learn how to make a simple castle, explained step by step for beginners, in this tutorial by @MammothCompany!

In this tutorial:


To follow along, you’re going to need a Unity virtual reality project open with a button. If you need help setting up a Unity project, go to our post How to Build a Unity Virtual Reality Game.

We’re using Unity v5.4.3f1. If you’re using a different version of Unity and find an incompatibility, drop us a comment down below with your question.

Step 1: Building Primitive Game Objects

First, set your button’s X position to 5 and Y position to 1. This button will control the player’s ability to enter the castle.

Let’s make a game object ro represent the castle! The first step is to make an empty game object in the Hierarchy. Name this object “Castle”. Give Castle the position 0 0 0.

Our castle also needs a floor for the player to walk on. To make a floor, right-click on “Castle” in the Hierarchy. Select 3D Object > Plane.

This creates a thin plane in your scene. Change Plane’s size by setting its Scale values to 2 1 10 in the Inspector.

unity game with plane and button
This is what the setup of your game should look like.

To change the color of the floor, make a new material in the Assets folder. Name the material “FloorMaterial.”

Change the color of FloorMaterial to a dark brown (RGB values such as 83 67 38.) Then apply the color to the plane by dragging and dropping FloorMaterial to Plane in the Scene.

Step 2: Building Castle Walls

Our castle needs walls! Using more primitive game objects, we can build castle walls.

In the Castle object in the Hierarchy, create a cube as a Child game object. That means Cube belongs to Castle in the Hierarchy.

Change Cube’s X Scale value to 15 and Y Scale value to 10.

a wall floor and button game object in unity
This is our game with a wall, button and floor.

Rename Cube “Wall”. We will surround the castle with walls.

To do so, duplicate Wall in the Hierarchy. This will make a new object named “Wall (1).” Give Wall (1) the Z position 30.

two walls and a button in a unity game
Our game now has a second wall!

Duplicate Wall (1) in the Hierarchy. Give Wall (2) the Z position 15.

Change the X Scale value of Wall (2) to 1, and the Z Scale value to 30.

Change the X position of Wall (2) until it meets up with the ends of Wall and Wall (1). The X Position value should be 7.

As such, we’ll have three walls of the castle done so far:

building a castle in unity
Our partially constructed castle

To make the final wall, duplicate Wall (2). Give Wall (3) the X position -7.

a box and playing arena in unity
Four walls complete!

To make an entryway into the castle, select the Wall object. Choose the Resizing tool, which is located above the Hierarchy:

location of the resizing tool in the unity editor
The Resizing tool is selected in this screenshot.

When you select the Resizing tool, blue lines will appear on Wall. This tool makes it easier to resize an object without setting values.

Click on the right side of Wall, and drag it to the left until its X Scale value is 5.12 and its X Position value is -4.94.

using the resizing tool in unity
We are cropping one of the walls of the castle.

Duplicate Wall. Make Wall (4)’s X position 4.94. We now have a gap in the walls of the castle!

a doorway with unity game objects
We now have a doorway!

Step 3: Building a Door

Let’s make a door to fill the gap while the player is outside the castle. Duplicate Wall (4). Change “Wall (5)” to “Door”. Grab the right edge of Door, and rotate it around. Then drag it down a bit.

Door’s Position should be -0.01 -0.14 0. Door’s Scale should be -4.8 9.7 1.

We will have Door move down when the player looks at Button. Then the player will be able to enter the castle.

castle with a door in unity
A door between castle walls

Step 4: Changing Wall Colors

To color the castle, create a material in the Assets folder. Name the material “CastleMaterial”. Give CastleMaterial a gray color with RGB values such as 111 111 111.

To apply CastleMaterial to all the walls of the castle, select the walls and door in the Hierarchy. In the Mesh Renderer component, expand the Materials property. Drag and drop CastleMaterial to the Element 0 field, as is being done in the next image. The castle’s color will become gray.

changing wall colors in unity
The castle with colors added

We’ve successfully built a castle in Unity using game object primitives! We’ll continue this game in the next post… unless you object…. What tutorials do you want to see next? Drop a comment below.


—Team Mammoth from Mammoth Interactive INC. Tutorial by Glauco Pires and Transcribing by Alexandra Kropova

Liked this tutorial? Get a free game development video course!

Leave a Reply

Your email address will not be published. Required fields are marked *