- Home /
 
An EOF Problem :(
expecting EOF, found 'else' This is the error i'm getting in one of my scripts, i got one fixed but now i'm baffled.
Here a section of my code where the error is.
function FixedUpdate (){ if(grounded){ moveDirection = new Vector3(Input.GetAxis("Horizontal"),0,0); moveDirection*=speed; if(Input.GetButton("Jump")){ moveDirection.y = jumpSpeed; animation.CrossFade("jump");
 
                   }
               "My problem is the else, once again"
 }  
   }else{
   moveDirection=new Vector3(Input.GetAxis("Horizontal"),moveDirection.y/speed,
   moveDirection*=speed;
 
               moveDirection.y -=gravity*Time.deltaTime; controller=GetComponent(CharacterController); flags=controller.Move(moveDirection*Time.deltaTime);
  
               grounded=(flags & CollisionFlags.CollidedBelow) !=1; 
Please help i'm new to coding, and can you tell me what i can do if i come across another Error within my scripts?
Answer by Jessy · Feb 22, 2011 at 12:37 PM
It would really help you if you could line up your braces. The problem is that you're terminating FixedUpdate before you use else. Count your brackets.
With a little better indentation, your script looks like this:
function FixedUpdate (){ if(grounded){ moveDirection = new Vector3(Input.GetAxis("Horizontal"),0,0); moveDirection*=speed; if(Input.GetButton("Jump")){ moveDirection.y = jumpSpeed; animation.CrossFade("jump");
 
                    }
 }  
 
               }
 
               else{ moveDirection=new Vector3(Input.GetAxis("Horizontal"),moveDirection.y/speed, moveDirection*=speed; moveDirection.y -=gravity*Time.deltaTime; controller=GetComponent(CharacterController); flags=controller.Move(moveDirection*Time.deltaTime); grounded=(flags & CollisionFlags.CollidedBelow) !=1; 
 
               
               It needs to look more like this:
function FixedUpdate () {
    if (grounded) {
        moveDirection = Vector3(Input.GetAxis("Horizontal") * speed, 0, 0);
        if (Input.GetButton("Jump")){
            moveDirection.y = jumpSpeed;
            animation.CrossFade("jump");
        }
    } else {
        // I can't work with this because some of it is missing.
    }
}
 
              I just copied my file from python to boo and im getting BCE0044: expecting "EOF", found 'class'. but its all well idented
Your answer