Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by ethankelly77 · Feb 16, 2016 at 09:05 PM · scrpting

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

42 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges