I am currently doing the Walker Bros ‘Lab 4 Project’ ‘2D Mario Game’ and I have a problem where it says line 85, 1 ‘Expects }, found ".’ When there is no line 85. Here are some screenshots-
Any help would gladly be appriciated!
Thanks!
I am currently doing the Walker Bros ‘Lab 4 Project’ ‘2D Mario Game’ and I have a problem where it says line 85, 1 ‘Expects }, found ".’ When there is no line 85. Here are some screenshots-
Any help would gladly be appriciated!
Thanks!
This error (usually) means that you’re missing or have an extra squiggly bracket - { or } (not sure what the technical term for them are). I’m pretty sure that if you put a closing squiggly bracket } on a new line at the end of the script, it will work. If not, post the entire script and I will look it over.
Fixed that problem, new one now >.>
Alright fixed that problem
new problem has arised. Every time I go right, instead of having the idle, walk, run sprite, I automatically crouch. Can that be fixed?
var walkSpeed : float = 1.5; // speed of the standerd walk
var runSpeed : float = 2.0; // speed of the run
var fallSpeed : float = 2.0; // speed of falling down
var walkJump : float = 6.1; // jump height from walk
var runJump : float = 9.0; // jump height from run
var crouchJump : float = 10.0; // jump height from crouching
var gravity : float = 20.0; // force applied on character
var startPos : float = 0.0; // location for start position
var moveDirection : int = 0; // Direction that player faces start
private var velocity : Vector3 = Vector3.zero; // Speed of player and direction
function Update ()
{
var aniPlay = GetComponent ( “aniSprite”);
//aniPlay.aniSprite ( 16, 16, 0, 1, 16, 12);
var controller : CharacterController = GetComponent( CharacterController );
if ( controller.isGrounded )
{
velocity = Vector3 ( Input.GetAxis ( “Horizontal” ), 0, 0 );
}
if ( velocity.x == 0 moveDirection == 1 ) //idle right
{
aniPlay.aniSprite ( 16, 16, 0, 0, 16, 12); // animation to call sprite sheet
}
if ( velocity.x == 0 moveDirection == 0 ) // idle left
{
aniPlay.aniSprite ( 16, 16, 0, 1, 16, 12); // animation to call sprite sheet
}
if ( velocity.x < 0 ) // walk left
{
velocity *= walkSpeed; // move left based on walk speed
aniPlay.aniSprite ( 16, 16, 0, 3, 10, 15 );
}
if ( velocity.x > 0 ) // walk right
{
velocity *= walkSpeed; // move right based on walk speed
aniPlay.aniSprite ( 16, 16, 0, 2, 10, 15 );
}
if ( velocity.x < 0 Input.GetButton ( “Fire1” ) ) // run left
{
velocity *= runSpeed; // move/run left based on run speed
aniPlay.aniSprite ( 16, 16, 0, 5, 16, 24 );
}
if ( velocity.x > 0 Input.GetButton ( “Fire1” ) ) // run right
{
velocity *= runSpeed; // move/run right based on run speed
aniPlay.aniSprite ( 16, 16, 0, 4, 16, 24 );
}
if ( velocity.x == 0 Input.GetAxis ( “Vertical” ) < 0 )
{
if ( moveDirection == 0 )
aniPlay.aniSprite ( 16, 16, 0, 9, 16, 24 );
}
if ( moveDirection == 1 )
{
aniPlay.aniSprite ( 16, 16, 0, 8, 16, 24 );
}
if ( Input.GetButtonDown ( “Jump” ) !Input.GetButton ( “Fire1” ) )
{
velocity.y = walkJump;
}
if (Input.GetButtonDown ( “Jump” ) Input.GetButton ( “Fire1” ) )
{
velocity.y = runJump + 5;
}
if ( !controller.isGrounded )
{
velocity.x = Input.GetAxis ( “Horizontal”);
velocity.x *= walkSpeed;
}
if ( velocity.x < 0 ) //get last move direction- left
{
moveDirection = 0; // set moveDirection to left
}
if ( velocity.x > 0 ) //get last move direction to right
{
moveDirection = 1; // set moveDirection to right
}
velocity.y -= gravity * Time.deltaTime; // apply gravity
controller.Move ( velocity * Time.deltaTime ); // move the controller
}
Would you mind adding code tags to that script? It will make it much easier to read ![]()
Also, are you getting any errors in the console?