Unity Walking Simulator

While using the program Unity I was given some information about how to create and expand a walking simulator type game, much like that of the list below, only with a personal touch adding in some kind of challenge and overall goal for the player to get to.

  • Firewatch
  • The Stanley Parable
  • Gone Home
  • Everybody’s Gone To The Rapture
  • Proteus
  • Dear Esther
  • The Vanishing Of Ethan Carter

Room

We started by creating a small room with a table, chair, door and a key to unlock the door. After adding the items I decided to flesh out the room some more, I did this by changing the walls to have an indent and some shelves so that I could add intractable books with physics, so that if they were moved they could fall over. I also added different materials to make the room feel a bit less dull. I decided to go for the colour blue, as this colour is known for being a calming colour and I wanted the player to feel at peace, I will also use this type of colour theory, later on when expanding my game, such as using the colour red for the platforms as I would want the player to not be patient and subconsciously make mistakes. In my room I have also made everything destructible, meaning if you went over to the table it could fall apart, I did this to most items in my room by just adding a rigid body and a box collider to each, this means each object with both of these have physics but also cannot fall through the ground.

walking-sim-image-2
Desk With Key
walking-sim-image-3
Birds Eye View Of Room

Player

After creating the room I added a rigid body for our player, This allowed me to control the camera and add things, later on, such as a crosshair. With the ability to control the player and explore the room that I had created. After adding physics and colliders to some objects when you knocked into them they would fall over with the physics, this made the player feel as if what they could do can affect the game. I later had to adjust the speed and size of the character, I changed the size so that the room I had created felt like a good enough size. I also changed the speed of the player as I want to add some jumping puzzles later on when I add more rooms and the speed the player was going would have made the jumps hard to calculate.

Flashlight

When creating the flashlight, I had to import a spotlight and attach it to the Ridgid body that represented the player. Where you placed the spotlight in relation to the camera was important as it would move with the player but before I added some code would not move with the players head, meaning if the player looked up or down the spotlight would not move.

flashlight-code
Code For Flashlight

The code above says in simple that when the key F is pressed then change the spotlights intensity to 1 turning it on or off when the F key is pressed.  The first line, line (9) is continuously checking for an update, the update being on line (10) that says if there is an input of the key being pressed, the key being F then go onto next line. The final line, line (11) simply changes the spotlight named flashlight. It changes the intensity of the light from 1 to 0 to simulate the flashlight being turned on and off in the game world.

Overall Code

only-pick-key-if-close-code
Code For Key Pick Up And Door Open

In this script the code first checks, if the Ridgid body (player) is close to the object named key, the code then goes on to say if the player is less than Vector3 away then destroy the key and rotate the door by coordinates (0, 80, 0) meaning rotate 80′.

The first line of code in this script on line (9) says that when the player clicks on the mouse the line underneath line (10) then does a quick check to see if the player is close to the object, in this case being the key, of vector 3. Line (11) then says if the player is within the distance vector 3 then do next line. Line (13) then destroys the game object (the key) and line (14) rotates the onject named door by 80′ so that it appears open.

walking-sim-code-text-disription
Code For Visual Description

This script implements a feature where when the player looks at an object in the game with this script attached to it, the text input into the script box will be displayed on the player’s screen.

The new thing in this script is the ‘usingUnityEngine.UI;’ as this creates a new area on the unity creating map that is a representation of the player’s screen so anything attached to the screen will show up in-game, this could be used to add a crosshair, a helmet effect or in this case a text box that describes what the player sees.

The next two lines of code (9) and (10) first say when the player’s mouse crosses the path with an object with this script on it, the script will then search for what text has been put into the box and then displays it on the player’s screen.

What Will I Add?

Going forward I will go in and expand the game world and add new rooms, I will most likely be making the game into a parkour type game where you jump from block to block trying to get to the next area. I will also add new scenes between levels and some extra features such as music and a working inventory system where you can pick up items.

The game will be difficult making the player redo complete areas if they fail to get passed, I would also like to add in a checkpoint system and place them around in areas where they are rewarding to get, making the player work for them.

Some PowePoints On Unity and the coding, detialing on what you need to do in order to get different features such as the flashlight and crosshair mentioned in this post.

room-one

room-2

radio-and-ray-casting

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s