Project
Roll-a-ball
Environment and Player
Tutorial
Beginner
25 Mins
Overview
Overview
You have completed 0% of this Tutorial.
1.
Setting up the Game
2.
Moving the Player
Summary
The Roll-a-ball Project is a simple rolling ball game that teaches you many of the principles of working with Unity.
The 2nd of 4 tutorials in the project demonstrates how to create a new Unity project, add some "primitive" shapes, and create a new material to change the color of the shapes. Then, we implement physics and add a simple C# script to let the player control the ball with the keyboard.
Roll-a-ball tutorials:
  1. Introduction to Roll-a-ball
  2. Environment and Player
  3. Camera and Play Area
  4. Collecting, Scoring, and Building the Game
Language
English
Recommended Unity Versions
5 and Above
1.
Setting up the Game
Creating a new project and setting up the basic game.

2.
Moving the Player
Moving the player object using player input and physics forces.
This is the current state of this script, as of the end of this lesson. This script will continue to change and mature in later lessons.

PlayerController

using UnityEngine; using System.Collections; public class PlayerController : MonoBehaviour { public float speed; private Rigidbody rb; void Start () { rb = GetComponent<Rigidbody>(); } void FixedUpdate () { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical"); Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); rb.AddForce (movement * speed); } }

Woohoo! You nailed this tutorial.
Continue rocking your Roll-a-ball project.
Next Step:
Camera and Play Area
Tutorial
Beginner
10 Mins
Part of: