- Home /
Assets/FPSC/Scripts/Player.js(27,29): BCE0044: expecting :, found '='.
Ok, so im kinda new to java script and im starting to get the hang of it, im working on an FPS and the code i use to do iron sights with i get an error on (27,29)
var PlayerState : float;
var PlayerAnimSec : GameObject;
var PlayerMotor : CharacterMotor;
var WalkingSpeed : float = 6;
var SprintingSpeed : float = 8;
var PlayerBossController : CharacterController;
function Update ()
{
PlayerStateController();
PlayerAnims();
}
function PlayerStateController()
{
if ((Input.GetAxis("Vertical") !=0 || Input.GetAxis("Horizontal") !=0))
{
if (Input.GetButton("Sprint")&&!Input.GetMouseButtonDown(2))
{
PlayerState = 2;
}
else if (Input.GetButton("Sprint") && !Input.GetMouseButtonDown(1));
{
PlayerState = 3;
}
else
{
PlayerState = 1;
}
}
else
{
PlayerState = 0;
}
}
function PlayerAnims()
{
if (PlayerState == 0)
{
PlayerAnimSec.animation.CrossFade("IdlePistol");
}
else if (PlayerState == 1)
{
PlayerAnimSec.animation.CrossFade("WalkPistol");
PlayerMotor.movement.maxForwardSpeed = WalkingSpeed;
PlayerMotor.movement.maxBackwardsSpeed = WalkingSpeed/2;
PlayerMotor.movement.maxSidewaysSpeed = WalkingSpeed;
}
else if (PlayerState == 2)
{
PlayerAnimSec.animation.CrossFade("WalkPistol");
PlayerMotor.movement.maxForwardSpeed = SprintingSpeed;
PlayerMotor.movement.maxBackwardsSpeed = SprintingSpeed/2;
PlayerMotor.movement.maxSidewaysSpeed = SprintingSpeed;
}
else if (PlayerState == 3)
{
PlayerAnimSec.animation.CrossFade("AimIn");
PlayerMotor.movement.maxForwardSpeed = WalkingSpeed/0.8;
PlayerMotor.movement.maxBackwardsSpeed = WalkingSpeed/3;
PlayerMotor.movement.maxSidewaysSpeed = WalkingSpeed/0.8;
}
}
Any Ideas?
Great, now I see what the two answers below saw before me :)
Answer by perchik · Sep 13, 2013 at 05:21 PM
It looks like you have an incorrect ; at the end of this line:
else if (Input.GetButton("Sprint") && !Input.GetMouseButtonDown(1));
Answer by flaviusxvii · Sep 13, 2013 at 05:22 PM
else if (Input.GetButton("Sprint") && !Input.GetMouseButtonDown(1));
The semi-colon at the end of that line is REALLY BAD. Remove it.
thanks ill do that now, ive been struggling with this code for almost 6 hours now.
6 hours? Learn to debug, that was a tough one to spot. With debugging, it shouldn't take you more than a couple of $$anonymous$$utes. If you're on $$anonymous$$onodev, or VS.
Your answer
![](https://koobas.hobune.stream/wayback/20220613114107im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
BCE0044: expecting (,found 'RayShoot' 1 Answer
Snow based questions 2 Answers
Emit when tag collision 3 Answers
SCRIPT NOT WORKING 2 Answers
ONGUI not working correctly, does code placement matter? 1 Answer