• 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 $$anonymous$$ · Apr 27, 2017 at 08:04 PM · game development

when I try to play game i cant

when I try to play game i get a message saying compiling errors must be fixed before game can be played

Comment
Add comment · Show 1
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
avatar image Jawchewa · Apr 28, 2017 at 12:58 AM 0
Share

Have you looked in the console window to see if any compiler errors exist in the project? Your scripts must be compilable and without errors for unity to allow you to run them. You should be able to find the console window in your editor, and it will tell you what errors exist in your project, and usually give you a hint on where to find them. alt text

error.png (16.3 kB)

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Jawchewa · Apr 28, 2017 at 08:33 PM

Looking at your code, I can notice several issues with your formatting that would cause compiler errors. The biggest one is probably that you are using parenthesis to contain your functions, when you should be using curly braces. So instead of this:

 function Update () (
 /*code*/
 )

It should be like this:

 function Update () {
 /*code*/
 }

Also, you don't literally need a semicolon after every line. Only put them after statements inside of a function, and declarations outside. For instance, you have a semicolon after the opening brace of each of your functions like

 function Update () (;

Those semicolons, and the semicolons after the function definitions are unnecessary.

finally, you can't actually call var target = transform outside of a function. You will need to move that inside one of the Start or Awake functions.

 var target;
 
 function Start() {
     target = transform;
 }

So the final fix of your code, as far as formatting goes would be something like this:

 var target;
 
 function Start() {
     target = transform;
 }
 
 function OnMounseDown () {
     this.transform.position = target.position; 
     this.transform.parent = GameObject.Find("FPSController").transform; 
     this.trasnform.parent = GameObject.Find("FirstPersonCharacter").transform; 
 }
 
 function OnMouseUp () {
     this.transform.parent = GameObject.Find("FPSController").transform;
     this.transform.parent = null; 
 }

I would probably recommend looking through a few more tutorials for javascript formatting. But I hope this helps!

Comment
Add comment · Share
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
avatar image
0

Answer by $$anonymous$$ · Apr 28, 2017 at 08:03 PM

thank you very much for your help. following is the script i created maybe by looking at it you can see what are the compiling errors in it?this is the script i wrote following the directions on the youtube video is it possible for you to see what is the unexpected token. Unexpected toke is the error message Im getting below my console. I did not have semi colons after all sentences, and I thought that was the problem, but after adding semi colon to all sentences I still get the same error message.

var target = transform;

function Update () (; )

function OnMounseDown () (; this.transform.position = target.position; this.transform.parent = GameObject.Find("FPSController").transform; this.trasnform.parent = GameObject.Find("FirstPersonCharacter").transform; );

function OnMouseUp ()(; this.transform.parent = GameObject.Find("FPSController").transform; this.transform.parent = null; );

Comment
Add comment · Share
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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

98 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 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 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

How to create iOS game app? Can you do that in Unity3D on a Windows computer? 1 Answer

2D RPG Game Management - How Do I Approach It? 0 Answers

Possible to make a desktop digital pet with unity?,Is it possible to make the unity window transparent while game is running? 1 Answer

Why doesn't my game function properly after building it? 0 Answers

Daily challenges in game 0 Answers


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