Prototyping a Unity Project: A simple scene with interactions

As we looked at how to create a Unity Project in our previous article, we will setup a simple scene to demonstrate motion and interactions.

Objective: Set up our GameObject's with components to allow for interactions and movement.

We can setup our GameObject’s Floor and Player Character with appropriate component's.

We replace the default Mesh Collider with a primitive Box Collider, it’s cheaper for performance cost’s than using a Mesh Collider for a simple shape.

Next we will add a Rigidbody component to our Player Character in the Inspector. This allows us to enable use of the PhysX Engine.

Having our Rigidbody attached to our Player Character can also affect the children component’s inside the parent object.

Enabling Gravity on our Rigidbody will add gravity and we can toggle it on and off as desired.

We can make our Player Character move with a Rigidbody component attached with forces and slopes. Additionally, we can move within Script’s.

We will make a new script called PlayerController.

Our PlayerController Class is responsible for Player Character information to store for our game logic.

Now that we have access to our Rigidbody or ‘rB’, we can Null Check to see if it has been destroyed or missing so we don’t run into frequent error’s in the future.

We can simply return the condition if the Rigidbody is not null.

Moving our Player Character in Update.

The Console will output if we have held down the ‘W’ Key (GetKey) / (GetKeyDown) is a single press.

Applying Movement with our Rigidbody.

Currently we have a basic implementation to apply movement with our Rigidbody, and we need to make a speed amount for it to work properly.

We can adjust our speed variable in the Inspector.

So we have Rigidbody movement now in the forward direction when the W-key is held down.

Challenge: Complete the Input values to reflect the final result below.

Final result of the Rigidbody ‘rB’ movement.




Game Developer focused in Unity with experience in Unreal Engine, Former Race Car Driver

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Separate Redis Store in Laravel

Scrum Master Anti-Patterns

How to Setup Your Programming Project on a Linux Virtual Machine using Vagrant

Tezos Blockchain cycle 415 stats

{UPDATE} De A a Z aprendizaje del alfabeto y escritor para Hack Free Resources Generator

Microsoft is offering an excellent framework to support cloud migration and adoption process…

How to Use “Data Flashback” on ApsaraDB for Redis to Recover Data by Time Point

My First Mentoring Experience at ngGirls 👩‍💻

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Zac Bogner

Zac Bogner

Game Developer focused in Unity with experience in Unreal Engine, Former Race Car Driver

More from Medium

Skeleton Damage Animation

How did I code my first video game?

My journey becoming a Unity game developer: 2.5D Infinite Runner-Ledge Grab System-Pt3