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 programmer1 · Sep 26, 2012 at 10:30 PM · javascriptsemicoloninsert

; expected insert semicolon at the end

 var speed; - 3.0;
 var rotateSpeed; - 3.0;
 
 function Update ()
 {
     var controller : CharacterController; - GetComponent(CharacterController);
     
         // Rotate around y - axis 
         transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
         
         // Move forward / backward
         var forward; - transform * TransformDirection(Vector3.forward);
         var curSpeed; speed Input.GetAxis; ("Vertical");
         controller.SimpleMove(forward * curSpeed);
  }
  
  @script RequireComponent(CharacterController)

Both Monodevelop and Unity say that i need a semicolon straight after the Input.GetAxis but i already have one there. I am only 12 and a beginner programmer. Any help appreciated it is also in javascript if that is any help

Comment
Add comment · Show 11
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 Screenhog · Sep 26, 2012 at 10:30 PM 0
Share

Please use the 101010 button to convert your code into a form that is more readable.

avatar image programmer1 · Sep 26, 2012 at 10:35 PM 0
Share

would this fix the script completely?? Thanks for the help

avatar image programmer1 · Sep 26, 2012 at 10:40 PM 0
Share

screenhog that only created more issues now it says unexpected token at the two lines that i put a colon on

avatar image zachy64 · Sep 26, 2012 at 10:42 PM 0
Share

Is it alright if I rewrite this script in C# for you? I don't really know UnityScript as well as C#.

What is this supposed to do? $$anonymous$$ove the character? You can just use the normal fps controller or something

avatar image Screenhog · Sep 26, 2012 at 11:02 PM 0
Share

No, that won't fix the entire script. To be honest, now that I see your script in a readable form, I'm not quite sure what you've written or what you're trying to do.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Screenhog · Sep 26, 2012 at 10:32 PM

You have many extra semicolons, and generally seem to be mixing up colons and semicolons.

For instance, speed and rotateSpeed in your first lines should have a = instead of a ; after them:

 var speed = -3.0; 
 var rotateSpeed = -3.0;
Comment
Add comment · Show 3 · 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 Eric5h5 · Sep 26, 2012 at 10:55 PM 1
Share

That still won't work...it needs to be

 var speed = -3.0;
 var rotateSpeed = -3.0;
avatar image Screenhog · Sep 26, 2012 at 11:02 PM 0
Share

Duh... sorry about that, don't know what I was thinking.

avatar image Bunny83 · Sep 27, 2012 at 04:07 AM 0
Share

@Screenhog: Ins$$anonymous$$d of posting that comment (or at least in addition) you should have fixed your answer by editing it ;)

I've fixed it for you, so i don't have to downvote it ;)

avatar image
0

Answer by CaioRosisca · Sep 26, 2012 at 11:49 PM

Try that

 var speed : float = -3.0;
 var rotateSpeed : float = - 3.0;
 
 function Update ()
 {
     var controller : CharacterController = GetComponent(CharacterController);//I think it should be ("CharacterController") //with ""
 
        // Rotate around y - axis 
        transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
 
        // Move forward / backward
        var forward = transform.TransformDirection(Vector3.forward);
        var curSpeed = speed * Input.GetAxis("Vertical");
        controller.SimpleMove(forward * curSpeed);
  }
 
  @script RequireComponent(CharacterController)
Comment
Add comment · Show 4 · 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 programmer1 · Sep 27, 2012 at 12:02 AM 0
Share

Caio it still isnt working it says i need a semicolon after speed = but when i put one there it creates more problems

avatar image Screenhog · Sep 27, 2012 at 12:13 AM 0
Share

What does the "var curSpeed = speed Input.GetAxis("Vertical");" line mean? What was it supposed to do?

Perhaps you wanted "speed * Input.GetAxis("Vertical");"

avatar image CaioRosisca · Sep 27, 2012 at 03:41 AM 0
Share

@Screenhog is right, my bad. it should be: var curSpeed = speed*Input.GetAxis("Vertical");

the line "var curSpeed = speed Input.GetAxis("Vertical");" sets the variable curSpeed to the input the engine receives from axis "vertical"(default W and S keys), the value is a range between -1 and 1..then it times speed to get a bigger number..then it's usedto move the player on that speed

avatar image Bunny83 · Sep 27, 2012 at 04:12 AM 0
Share

Don't suggest to use GetComponent with a string. You will lose the type of the returned component. Since the variable is explicitly typed in this case it would work, but in general use the Type and not string version.

Btw: You can edit any post you make here. I'll fix it for you

edit
I also fixed the "var forward" line. You can't multiply a component with a function ;) The function TransformDirection is actually a part of transform, so you need a dot "."

ps: The code in the question is actually a totally messed up version of the sample in Simple$$anonymous$$ove. I'm not sure how he managed to get this sample that wrong (since you can just copy it). $$anonymous$$aybe he's just a spammer begging for karma? :D

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

14 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

Related Questions

';' Expected, Tried everything. How do I do this? 1 Answer

expected. Insert a semicolon at the end. When the end that it says, is a } Could someone help us fix this? 2 Answers

js(9,31): UCE0001: ';' expected. Insert a semicolon at the end. 2 Answers

Compiler error UCE0001: ';' expected 1 Answer

';' expected. Insert a semicolon at the end. I already have a ; 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