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 bula · Dec 10, 2011 at 06:40 PM · javascriptcharactermove

Sprint Script Error?!!!!

Here is the script.

 //The Sprint script
 if (Input.GetButtonDown("Shift")) {
     maxForwardSpeed = maxSprintSpeed ;
     maxSidewaysSpeed = maxSprintSpeed ;
     maxBackwardSpeed = 0 ;
 }

 if (Input.GetButtonUp("Shift")) {
     maxForwardSpeed : float = 20.0;
     maxSidewaysSpeed : float = 20.0
     maxBackwardsSpeed : float = 10.0
 

Any help will be very apreciated. Ty

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 Durante · Dec 10, 2011 at 07:04 PM 0
Share

what exactly are you trying to get to or find out...cause from what I see the script looks perfect I cant find any errors could you please be more specific.

Thank you Durante Productions.

avatar image bula · Dec 10, 2011 at 07:15 PM 0
Share

1.Assets/Standard Assets/Character Controllers/Sources/Scripts/Character$$anonymous$$otor.js(37,9): BCE0044: expecting }, found 'if'. 2.Assets/Standard Assets/Character Controllers/Sources/Scripts/Character$$anonymous$$otor.js(37,42): UCE0001: ';' expected. Insert a semicolon at the end. 3.Assets/Standard Assets/Character Controllers/Sources/Scripts/Character$$anonymous$$otor.js(38,21): BCE0044: expecting :, found '='.

Theese are the errors and i dont know what to do to clear them Im trying to make the char sprint.

4 Replies

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

Answer by Durante · Dec 10, 2011 at 07:40 PM

This is how your code should look

 var maxForwardSpeed     : float = 20.0;
 var maxSidewaysSpeed    : float = 20.0;
 var maxBackwardsSpeed    : float = 10.0;
 var maxSprintSpeed        : float = 30.0;

 if (Input.GetButtonDown("Shift")) 
 {
  maxForwardSpeed = maxSprintSpeed ;
  maxSidewaysSpeed = maxSprintSpeed ;
  maxBackwardSpeed = 0 ;
 }

 if (Input.GetButtonUp("Shift")) 
 {
  maxForwardSpeed = maxForwardSpeed;
  maxSidewaysSpeed = maxSidewaysSpeed;
  maxBackwardsSpeed = maxBackwardsSpeed;
 }

thats the basic setup for your char to run as far as the walk functions you have to script them out if you havent already.

thank you Durante Productions

Comment
Add comment · Show 6 · 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 FLASHDENMARK · Dec 10, 2011 at 08:11 PM 0
Share

Execpt you'll need to put it in the Update() function, but everything else looks fine.

avatar image Durante · Dec 10, 2011 at 08:53 PM 0
Share

he could also use the "return" in the

if (Input.GetButtonUP ( " shift " ) ) { return; }

that would work too i belive

avatar image bula · Dec 13, 2011 at 10:08 PM 0
Share

Update() Function ? I'm kinda new with scripting and how would this function look like? Ty

avatar image bula · Dec 13, 2011 at 10:12 PM 0
Share

1 more thing I need to name this shift i think.....How do i do this?Any help will be apreciated

avatar image Durante · Dec 13, 2011 at 10:50 PM 0
Share

you would put

Function update () { where you are reading these words the script that i rewrote for you would go in here replacing thses words. }

and your comment "1 more thing I need to name this shift i think.....How do i do this?Any help will be apreciated" could u be a little bit more clear on that one pls.

Show more comments
avatar image
0

Answer by BiG · Dec 10, 2011 at 07:18 PM

The errors seem clear to me, and they are evident. the last two lines need ";" at the end. The second "if" doesn't have the close bracket "}".

Comment
Add comment · 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
0

Answer by Durante · Dec 10, 2011 at 07:22 PM

I agree with BIG having read your errors that is exactly what needs to be done. close off the last two lines with the " ; " and then close of the argument with a " } "...and you should be good to go.

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 bula · Dec 10, 2011 at 07:27 PM 0
Share

//The Sprint script if( Input.GetButtonDown("Shift")) { maxForwardSpeed = maxSprintSpeed ; maxSidewaysSpeed = maxSprintSpeed ; maxBackwardSpeed = 0 ; }

 if (Input.GetButtonUp("Shift"))         {
 maxForwardSpeed : float = 20.0;
 maxSidewaysSpeed : float = 20.0;
 maxBackwardsSpeed : float = 10.0;

} Thats my script still not working

avatar image
0

Answer by Durante · Dec 16, 2011 at 10:41 PM

here you go i updated it i messed up when i rewrote it sry.

 var maxForwardSpeed     : float = 20.0;
 var maxSidewaysSpeed    : float = 20.0;
 var maxBackwardsSpeed   : float = 10.0;
 var maxSprintSpeed   : float = 30.0;

 if (Input.GetButtonDown("Shift")) 
 {
  maxForwardSpeed = maxSprintSpeed ;
  maxSidewaysSpeed = maxSprintSpeed ;
  maxBackwardSpeed = 0 ;
 }

 if (Input.GetButtonUp("Shift")) 
 {
  maxForwardSpeed = maxForwardSpeed;
  maxSidewaysSpeed = maxSidewaysSpeed;
  maxBackwardsSpeed = 0;
  maxSprintSpeed = 0;
 }

I hope this helps.

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 bula · Dec 16, 2011 at 11:32 PM 0
Share

$$anonymous$$ate it still dont works........ I dont know what is wrong but its not working.....You can check my channel for my question about this script... Its called "Errors for Good Script?!" I gaved there more details about the errors but as far as I know your script is good(Cheers) But is not working for me:( Check my channel.....

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Setting Scroll View Width GUILayout 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

I have a movement script, but how can i make it so i can move half the speed while in the air. 0 Answers

Translation of an object 2 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