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 MrVarron · Feb 11, 2013 at 07:07 PM · error message

unity say's: expecting :, found '='.

i want to make a character controller, but unity sayd that the script has an error here's the script:

 var walkSpeed: float = 7; 
 var crouchspeed: float = 3; 
 var runspeed: float = 15; 
 
 private var chMotor: CharacterMotor;
 private var ch: CharacterController;
 private var tr: Transform;
 private var height: float;
 
 
 function Start(){
 
 chMotor = GetComponent(CharacterMotor);
 
 tr = transform;
 
 ch = GetComponent(CharacterController);
 
 height = ch.height;
 
 }
 
 function Update(){
 
 var h = height;
 
 var speed = walkspeed;
 
 
 if(ch.isGrounded && Input.GetKey("left shift") || Input.GetKey("right shift"));{
 speed = runspeed
 
 }
 
 if(Input.GetKey("left control"));{
 h = 0.5 * height;
 speed = crouchspeed; 
 
 {
 
 
 chMotor.movement.maxForwardSpeed = speed; 
 var lastHeight = ch.height; 
 ch.height = Mathf.Lerp(ch.height,h,5*Time.deltaTime);
 tr.position.y +=(ch.height-lastHeight)/2;
 }
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 Graham-Dunnett ♦♦ · Feb 11, 2013 at 08:37 PM 2
Share

Unity also told you the exact line number that had the problem. What's the line number?

2 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by EHogger · Feb 11, 2013 at 09:24 PM

You've put ; on the end of the if statements which shouldn't be there. You've also missed the ; on line 31, and there is a bracket facing the wrong way on line 39.

Comment
Add comment · Show 5 · 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 MrVarron · Feb 15, 2013 at 04:32 PM 0
Share

ok thx on here, i've test it an now i can play BUT!!!! when i start the game, i can't move! i'm on one point and nothing else metter! thats a big problem that i can't go and run or crouch NOTHING! and the other error is:

UnityException: Input $$anonymous$$ey named: left control is unknown UnityEngine.Input.Get$$anonymous$$ey (System.String name) (at C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/UnityEngineInput.cs:254) $$anonymous$$ove.Update () (at Assets/$$anonymous$$ove.js:35)

please help me and when you've time please write it correct i need help!

avatar image MrVarron · Feb 15, 2013 at 04:39 PM 0
Share

i must say the error is here UnityException: Input $$anonymous$$ey named: left control is unknown UnityEngine.Input.Get$$anonymous$$ey (System.String name) (at C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/UnityEngineInput.cs:254) $$anonymous$$ove.Update () (at Assets/$$anonymous$$ove.js:35)

and the new skript

 var walkSpeed: float = 7; 
 var crouchspeed: float = 3; 
 var runspeed: float = 15; 
  
 private var ch$$anonymous$$otor: Character$$anonymous$$otor;
 private var ch: CharacterController;
 private var tr: Transform;
 private var height: float;
  
  
 function Start(){
  
 ch$$anonymous$$otor = GetComponent(Character$$anonymous$$otor);
  
 tr = transform;
  
 ch = GetComponent(CharacterController);
  
 height = ch.height;
  
 }
  
 function Update(){
  
 var h = height;
  
 var speed = walkSpeed;
  
  
 if(ch.isGrounded && Input.Get$$anonymous$$ey("left shift") || Input.Get$$anonymous$$ey("right shift")){
 speed = runspeed;
  
 }
  
 if(Input.Get$$anonymous$$ey("left control")){
 h = 0.5 * height;
 speed = crouchspeed; 
  
 }
  
  
 ch$$anonymous$$otor.movement.maxForwardSpeed = speed; 
 var lastHeight = ch.height; 
 ch.height = $$anonymous$$athf.Lerp(ch.height,h,5*Time.deltaTime);
 tr.position.y +=(ch.height-lastHeight)/2;
 }
avatar image EHogger · Feb 15, 2013 at 06:08 PM 0
Share

Input.Getkey("left control") is wrong. It should be Input.Getkey("left ctrl") or Input.Getkey($$anonymous$$eyCode.LeftControl)

You could find this out yourself st by checking the reference manual online. The error message tells you where the problem is each time, so just look up that function and check you understand it before asking on here. http://docs.unity3d.com/Documentation/ScriptReference/Input.Get$$anonymous$$ey.html

avatar image tuhinbhatt · Feb 15, 2013 at 06:50 PM 0
Share

Ins$$anonymous$$d Try using this Input.Get$$anonymous$$ey($$anonymous$$eyCode.LeftControl) this should work.

avatar image MrVarron · Feb 16, 2013 at 08:23 PM 0
Share

thx i try now

avatar image
0

Answer by MrVarron · Feb 15, 2013 at 03:36 PM

Ok thx for the fast answer, i will try to use it (in the evening) and than i write the result, but thx on here, i hope you show my next answer and help me tomorrow or evening.... see u soon

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 flaviusxvii · Feb 15, 2013 at 04:51 PM 0
Share

Don't answer.. comment on answers.

avatar image MrVarron · Feb 15, 2013 at 06:02 PM 0
Share

ok sure...

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

12 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

Related Questions

errror message 1 Answer

2 errors im stuck on. 1 Answer

GUI.Box error 1 Answer

Strange error with unity. 1 Answer

Unity Pro trial crashing due to an asset 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