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 classyjakey · Feb 26, 2014 at 05:57 PM · errorunexpected

Parser error for code...

I'm trying to make a gravity switch function but i keep getting this at line 14. Unexpected symbol ` (expecting bla bla). Here is my code.

 using UnityEngine;
 using System.Collections; 
 
 public class GravitySwitch : MonoBehaviour {
 
     // Use this for initialization
     void Start () {
     
     }
 
 
     // Update is called once per frame
     void Update () {
         function OnMouseDown () {
             Physics.gravity = Vector3 (0, 1.0, 0);
         }
         function OnMouseUp () {
             Physics.gravity = Vector3 (0, -1.0, 0);
         }
 }
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 perchik · Feb 26, 2014 at 06:09 PM 0
Share

In general when you're posting about an error, you should put the actual text of the error, to help us identify the problem. (although, in this case, @zentiu is correct)

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Zentiu · Feb 26, 2014 at 06:07 PM

info is plenty for now but in the future if you have an error.. make sure you give us the entire error.

now for your problem:

try this

     void Update () 
     {    //if left mousebutton is pressed.
         if(Input.GetMouseButtonDown (0))
         {
              Physics.gravity = Vector3 (0, 1.0, 0);
         }
          // if left mousebutton is released.
         if(Input.GetMouseButtonUp (0))
         {
             Physics.gravity = Vector3 (0, -1.0, 0);
         }
     }
 
 
 
Comment
Add comment · Show 7 · 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 perchik · Feb 26, 2014 at 06:08 PM 0
Share

ah, I wasn't paying attention to the code.. I deleted my answer. Well done.

avatar image Zentiu · Feb 26, 2014 at 06:11 PM 0
Share

sorry, didn't see your answer.. I was to busy fighting my new keyboard trying to enter this code :S

avatar image perchik · Feb 26, 2014 at 06:11 PM 0
Share

oh no, $$anonymous$$e was quite wrong. I didn't see notice the extra function calls

avatar image classyjakey · Feb 27, 2014 at 05:03 PM 0
Share

Still dosen't help... I get the same error : Assets/Standard Assets/Image Effects (Pro Only)/gravityswitch.cs(20,9): error CS8025: Parsing error

avatar image perchik · Feb 27, 2014 at 05:06 PM 0
Share

what is line 20 in your actual code?

Also for the record, that's a different error.

Show more comments

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

23 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

Related Questions

Cant Receive Exp 1 Answer

No appropriate version of 'UnityEngine.Object.Instantiate. Please Help :( 1 Answer

Error unexpected symbol 'internal' What is wrong with this? 0 Answers

How can I convert this code to Unity Android? 1 Answer

CAN SOMEONE FINALLY HELP ME! 3 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