Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by WingBro · Nov 10, 2014 at 02:06 AM · c#monodevelopparsing error

CS8085 Parsing Error?

I am getting the error:

alt text

The first line is always the one getting the error. "var defaultCam : Game Object;" Is the 4th line. Here is my code:

 var defaultCam : GameObject;
 var playerObject : GameObject;
 var isEnabled : boolean;
 var shift : boolean;
 var ctrl : boolean;
 var accelerationAmount : float = 3;
 var accelerationRatio : float = 1;
 var slowDownRatio : float = 0.5;
 var flySpeed : float = 0.5;
 
 function Update()
 {
     if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift))
     {
         shift = true;
         flySpeed *= accelerationRatio;
     }
    
     if (Input.GetKeyUp(KeyCode.LeftShift) || Input.GetKeyUp(KeyCode.RightShift))
     {
         shift = false;
         flySpeed /= accelerationRatio;
     }
     if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl))
     {
         ctrl = true;
         flySpeed *= slowDownRatio;
     }
     if (Input.GetKeyUp(KeyCode.LeftControl) || Input.GetKeyUp(KeyCode.RightControl))
     {
         ctrl = false;
         flySpeed /= slowDownRatio;
     }
     if (Input.GetAxis("Vertical") != 0)
     {
         transform.Translate(-defaultCam.transform.forward * flySpeed * Input.GetAxis("Vertical"));
     }
     if (Input.GetAxis("Horizontal") != 0)
     {
         transform.Translate(-defaultCam.transform.right * flySpeed * Input.GetAxis("Horizontal"));
     }
     if (Input.GetKey(KeyCode.E))
     {
         transform.Translate(defaultCam.transform.up * flySpeed*0.5f);
     }
     else if (Input.GetKey(KeyCode.Q))
     {
         transform.Translate(-defaultCam.transform.up * flySpeed*0.5f);
     }
     if (Input.GetKeyDown(KeyCode.F12))
         switchCamera();
     if (Input.GetKeyDown(KeyCode.M))
         playerObject.transform.position = transform.position; //Moves the player to the flycam's position. Make sure not to just move the player's camera.
 }
 function switchCamera()
 {
     if (!isEnabled) //means it is currently disabled. code will enable the flycam. you can NOT use 'enabled' as boolean's name.
     {
         transform.position = defaultCam.transform.position; //moves the flycam to the defaultcam's position
         defaultCam.camera.active = false;
         this.camera.active = true;
         isEnabled = true;
     }
     else if (isEnabled) //if it is not disabled, it must be enabled. the function will disable the freefly camera this time.
     {
         this.camera.active = false;
         defaultCam.camera.active = true;
         isEnabled = false;
     }
 }


Can anyone help me here on why? I am using a script I found here:

Click Here to view website

pars.png (2.8 kB)
Comment
Add comment · Show 3
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 MrSoad · Nov 10, 2014 at 01:55 AM 0
Share

defaultCam is a camera so it should be declared as one, not as a GameObject. Like :

 public var defaultCam : Camera;

avatar image robertbu · Nov 10, 2014 at 02:08 AM 0
Share

Your code does not generate a compiler error for me, but the warnings are something you might want to deal with. For example, line 60 should be:

    defaultCam.SetActive(false);
avatar image WingBro · Nov 10, 2014 at 12:58 PM 0
Share

@ $$anonymous$$r Soad No that's not the problem, if I place that line of code at the bottom of all the variables the first line is always the one getting the error. I need to paste this in a JS file. Cause this is in a C# file.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Kiwasi · Nov 10, 2014 at 03:05 AM

This is JavaScript written inside a C# script file. Copy this into a .js file and it should work fine.

Parsing error is the error thrown when the compiler can't figure things out and gives up.

Comment
Add comment · Show 1 · 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 WingBro · Nov 10, 2014 at 12:56 PM 0
Share

I haven't tried this yet, but now that I look more closely i should have known that function is for JS and void is for C#. I'm going to try this! Thx!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

What parsing errors do i have 1 Answer

monodevelop 4.0.1 run with empty 0 Answers

How to use ArrayList.IndexOf and Conver.ToInt32 1 Answer

Can I call a js script method inside a C# dll project? 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