- Home /
Sprint Error script?
I just made a script for sprinting:
//The Sprint script
if( Input.GetButtonDown("Shift")) {
maxForwardSpeed = maxSprintSpeed ;
maxSidewaysSpeed = maxSprintSpeed ;
maxBackwardSpeed = "0" ;
} if (Input.GetButtonUp("Shift")) { maxForwardSpeed = maxForwardSpeed ; maxSidewaysSpeed = maxSidewaysSpeed ; maxBackwardSpeed = maxBackwardSpeed ; } What is the problem with this script?
Need more of your script to deter$$anonymous$$e what's wrong, the error along with it would be helpful as well.
And the errors are : 1.
Assets/Standard Assets/Character Controllers/Sources/Scripts/Character$$anonymous$$otor.js(37,42): UCE0001: ';' expected. Insert a semicolon at the end.
2. Assets/Standard Assets/Character Controllers/Sources/Scripts/Character$$anonymous$$otor.js(37,9): BCE0044: expecting }, found 'if'.
3. Assets/Standard Assets/Character Controllers/Sources/Scripts/Character$$anonymous$$otor.js(38,21): BCE0044: expecting :, found '='.
The compiler comment "Insert a semicolon at the end." seems pretty self-evident.
Its not if you think its telling me to add a semicolon after a if function or is it?
The code you provided contains no errors other than "cannot convert string to int" and "WARNING: Assignments made to same expression. Did you mean to assign to something else?"
BiG already fixed the "cannot convert string to int" error, and the other are just warnings meaning you make no change whatsoever.
The code you gave use are not producing the errors something else must be doing so.
Answer by ptdnet · Dec 06, 2011 at 05:17 PM
this:
maxForwardSpeed = maxForwardSpeed ;
doesn't make any sense.
Even if it doesn't make sense, it would not give errors, or at least not the ones the OP described.
Answer by BiG · Dec 07, 2011 at 07:41 AM
I imagine maxBackwardSpeed as an Integer variable. If so, you have to declare it as
maxBackwardSpeed = 0;
and not as
maxBackwardSpeed = "0";
Yeah...still no diffrence for the error.. Any more ideas? Need more script?