I keep getting the error "Assets\scripts\PlayerMovement.cs(28,42): error CS1002: ; expected" from unity console but, I can't find whats wrong in the area below.
(Input.GetAxisRaw("Horizontal"))
{
stopwatch.Start();
}
if ((stopwatch > 1) && (stopwatch < 2))
{
runSpeed = (runSpeed * 1.5);
}
else if (stopwatch >= 2)
{
runSpeed = (runSpeed * 2);
}
if (Input.GetAxisRaw("Horizontal") = 0)
{
stopwatch.Stop();
}
I tried removing the parenthesis and moving around the semicolons. I don't know what else I can do because I'm learning this stuff as a I go.
I'm trying to make it where the longer the player is moving left or right the faster they go in 3 different speeds. The default speed of 40, the second speed which is 60, and the third and final speed which is 80.
CodePudding user response:
Why did you put a single equal-sign in the last if-statement, you should try to put a second equal-sign in the last if-statement.
Because of that, it sets your method is set to zero in the if-statement but is not checked whether it is zero or not. Just replace
if(Input.GetAxisRaw("Horizontal")=0)
With
if(Input.GetAxisRaw("Horizontal")==0)
Also in your very first line of code there is no if-statement, but the brackets exist, also in the very first line the condition is not check whether you are moving, so replace
(Input.GetAxisRaw("Horizontal"))
With
if(Input.GetAxisRaw("Horizontal")!=0)
that might help