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 _TC · Aug 28, 2013 at 02:02 PM · errorbugvoid

ANSWERED Unexpected symbol 'void' - I am new to coding please help me find the error

Here is the code, ik it is very basic:

using UnityEngine; using System.Collections;

public class FirstPersonController : MonoBehaviour {

 public float movementSpeed = 5.0f;
 public float mouseSensitivity = 5.0f;
 public float upDownRange = 60.0f
 
 // Use this for initialization

 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
     // Rotation
     
     float rotLeftRight = Input.GetAxis("Mouse X") * mouseSensitivity;
     transform.Rotate(0, rotLeftRight, 0);

     float rotUpDown = Input.GetAxis("Mouse Y") * mouseSensitivity;
     
     float currentUpDown = Camera.main.transform.rotation.eulerAngles.x;
     float desiredUpDown = currentUpDown - rotUpDown;
     
     Camera.main.transform.rotation = Quaternion.Euler(desiredUpDown, 0, 0);
     
     // movement
 
     float forwardSpeed = Input.GetAxis("Vertical") * movementSpeed;
     float sideSpeed = Input.GetAxis("Horizontal") * movementSpeed;
     
     Vector3 speed = new Vector3( sideSpeed, 0, forwardSpeed );
     
     speed = transform.rotation * speed;
     
     CharacterController cc = GetComponent<CharacterController>();
     
     cc.SimpleMove( speed );
     
 }

}

Comment
Add comment · Show 2
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 Lairinus · Aug 28, 2013 at 02:09 PM 0
Share

Honestly, I would close Unity and your compiler. I used to get a lot of errors like this, but a hard restart normally fixes it.

If it doesn't, what's the line number of the error?

avatar image perchik · Aug 28, 2013 at 02:09 PM 0
Share

Can you paste the full text of the error?

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by roojerry · Aug 28, 2013 at 02:11 PM

 public float upDownRange = 60.0f

This line needs a semi colon after it

 public float upDownRange = 60.0f;


When debugging errors like this, it is common that the error may actually occur on the statement before the line that is showing the error. The compiler won't know that you didn't mean to not close off that declaration, but it will get confused thinking that the next line of code is part of that statement, and throw an error

Comment
Add comment · Show 2 · 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 _TC · Aug 28, 2013 at 05:45 PM 0
Share

Thanks a lot this fixed it!

avatar image roojerry · Aug 28, 2013 at 05:47 PM 1
Share

No problem. Don't forget to mark the question as answered. Good luck developing!

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

18 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

Related Questions

Unity Crashes on startup 2 Answers

semicolon expected while semicolon is present 1 Answer

GetThreadContext failed (Unity 5) 0 Answers

Weird Error c# 1 Answer

Strange physics, rigidbody, iTween activity 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