- Home /
Error BCE0005 in Javascript
Hi all, just had a new problem with my code. I have Modified CharacterMotor.js (FPS Controller) to make my characters run, but i get these errors:
Assets/Standard Assets/Character Controllers/Sources/Scripts/CharacterMotor.js(342,46): BCE0005: Unknown identifier: 'currentSprintTime'.
Assets/Standard Assets/Character Controllers/Sources/Scripts/CharacterMotor.js(342,71): BCE0005: Unknown identifier: 'SprintCooldownOn'.
Assets/Standard Assets/Character Controllers/Sources/Scripts/CharacterMotor.js(371,43): BCE0005: Unknown identifier: 'maxSprintTime'.
This is the code:
// The maximum horizontal speed when moving
var maxForwardSpeed : float = 10.0;
var maxSidewaysSpeed : float = 9.0;
var maxBackwardsSpeed : float = 9.5;
// [CUSTOM] Sprint duration
var maxSprintTime : float = 20.0; // Time in seconds that player can sprint
var currentSprintTime : float = 20.0; // Initial Sprint Time
var SprintCooldownOn : boolean = false; // Sprint Cooldown Var
var SprintOn : boolean = false; // Tells if Player is Sprinting
function Update () {
if ( Input.GetKey( "left shift" ) && currentSprintTime > 0 && SprintCooldownOn == false ) // CUSTOM SPRINT SCRIPT
{
movement.maxForwardSpeed = 15.0;
movement.maxSidewaysSpeed = 14.0;
movement.maxBackwardsSpeed = 14.5;
SprintOn = true; // Sets Sprinting Mode ON
}
else
{
SprintOn = false;
}
if ( SprintOn == true && currentSprintTime > 0 )
{
currentSprintTime--; // Takes Time
}
if ( SprintOn == true && currentSprintTime == 0 )
{
SprintCooldownOn = true; // Sets Cooldown Mode ON
currentSprintTime++; // Adds Time
if ( currentSprintTime == maxSprintTime )
{
SprintCooldownOn = false;
}
}
if (!useFixedUpdate)
UpdateFunction();
}
The errors are on lines 342 and 371...and yet you only posted 57 lines here?
This might be a really stupid question (and slightly patronising), but have you saved your script since you made the changes?
Answer by jg2115 · Jul 04, 2013 at 09:54 PM
Instead try making it a separate script and calling the character motor like this:
private var chMotor: CharacterMotor;
private var ch: CharacterController;
function Start(){
chMotor = GetComponent(CharacterMotor);
ch = GetComponent(CharacterController);
}
and then you could adjust speed by
chMotor.movement.maxForwardSpeed = sprintspeed;
Ok thanks, i'm a newbie with javascript. Also, what's the variable ch for?
You don't need ch, you could just use it if you wanted to see if the player was jumping or on the ground. I don't know if you need that for your game.
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
Having a script variable update between two objects 1 Answer
Finding what scene number player is on and adding one.... 1 Answer
A variable im trying to pull from another script is reseting when it shouldn't? 0 Answers