New at Unity, Issues following Sams Teach Yourself
I recently bought a Sams Teach Yourself Unity Game Development and have come accross many issues. 1 is that the book is for Unity 4 but I downloaded Unity 5.3.2, the other is that the files they have associated to the book are outdated in a sense that heightmaps they give us are terrible and ive had to make my own. I have made a game and the scripting they are giving us is error filled. I have minor experince in coding, but dont understand how it goes with the book and I cant figure it out because so much of whats in the book is outdated. I will show you the codes that are given in the book.
Game Control Script: using UnityEngine; using System.Collections;
public class GameControlScript : MonoBehaviour {
//The amount of ellapsed time
private float time = 0;
//Flags that control the state of the game
private bool isRunning = false;
private bool isFinished = false;
//place holders for the player and the spawn point
public Transform spawnPoint;
public GameObject player;
//place holders for the scripts on the character controller
public CharacterMotor motorScript;
public MouseLook lookScript;
//This resets to game back to the way it started
private void InitLevel()
{
time = 0;
isRunning = true;
isFinished = false;
//move the player to the spawn point
player.transform.position = spawnPoint.position;
//Allow the character controller to move and
//look around
motorScript.enabled = true;
lookScript.enabled = true;
}
// Use this for initialization
void Start () {
//prevent the character controller
//from looking around
motorScript.enabled = false;
lookScript.enabled = false;
}
// Update is called once per frame
void Update () {
//add time to the clock if the game
//is running
if(isRunning)
time += Time.deltaTime;
}
//This runs when the player enters the finish
//zone
public void FinishedGame()
{
isRunning = false;
isFinished = true;
//freeze the character controller
motorScript.enabled = false;
lookScript.enabled = false;
}
//This section creates the Graphical User Interface (GUI)
void OnGUI()
{
if(!isRunning)
{
string message;
if(isFinished)
message = "Click to Play Again";
else
message = "Click to Play";
if(GUI.Button(new Rect(Screen.width / 2 - 70, Screen.height/2, 140, 30), message))
{
//start the game if the user clicks to play
InitLevel ();
}
}
//If the player finished the game, show the final time
if(isFinished)
{
GUI.Box(new Rect(Screen.width / 2 - 65, 185, 130, 40), "Your Time Was");
GUI.Label(new Rect(Screen.width / 2 - 10, 200, 20, 30), ((int)time).ToString());
}
//If the game is running, show the current time
else if(isRunning)
{
GUI.Box(new Rect(Screen.width / 2 - 65, Screen.height - 115, 130, 40), "Your Time Is");
GUI.Label(new Rect(Screen.width / 2 - 10, Screen.height - 100, 20, 30), ((int)time).ToString());
}
}
}
Finish Script:
using UnityEngine; using System.Collections;
public class FinishScript : MonoBehaviour {
//This is a place holder for the script that controls the game
public GameControlScript gameControlScript;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
//This states that when an object enters the finish zone, let the
//game control know that the current game has ended
void OnTriggerEnter(Collider other)
{
gameControlScript.FinishedGame();
}
}
Here are the errors that appear when I move the script codes into the script folder.
Assets/Scripts/GameControlScript.cs(6,6) error CS1003: syntax error, '.' expected Assets/Scripts/GameControlScript.cs(6,48) error CS8032 internal compiler error during parsing, run with -v for details
Your answer
Follow this Question
Related Questions
BCE0005 Unknown identifier: 'FirstPersonController' Help please 1 Answer
All the script stoped the update func when i lock the computer 1 Answer
Scripts worked but since 3 days its not working, please help. 0 Answers
How to attach a basic first person camera to a capsule? 1 Answer
My jump scripit wont work. i have been tryingtt o make it work for an eternity. please help. 1 Answer