- Home /
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
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.
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.
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
Execpt you'll need to put it in the Update() function, but everything else looks fine.
he could also use the "return" in the
if (Input.GetButtonUP ( " shift " ) ) { return; }
that would work too i belive
Update() Function ? I'm kinda new with scripting and how would this function look like? Ty
1 more thing I need to name this shift i think.....How do i do this?Any help will be apreciated
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.
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 "}".
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.
//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
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.
$$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
![](https://koobas.hobune.stream/wayback/20220613061948im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
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