Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

error CS1525: Unexpected symbol `}'

Discussion in 'Editor & General Support' started by Windyone, Nov 14, 2016.

  1. Windyone

    Windyone

    Joined:
    Nov 11, 2016
    Posts:
    8
    Help! I get the error above when, clearly, It isn't unexpected. Please Help!


    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Player : MonoBehaviour {
    5.  
    6.     public float speed = 50f;
    7.     public float jumpPower = 150f;
    8.     public float maxSpeed = 3f;
    9.     public bool grounded;
    10.     private Animator anim;
    11.     private Rigidbody2D rb2d;
    12.  
    13.     // Use this for initialization
    14.     void Start ()
    15.     {
    16.         rb2d = gameObject.GetComponent<Rigidbody2D> ();
    17.         anim = gameObject.GetComponent<Animator> ();
    18.     }
    19.  
    20.     // Update is called once per frame
    21.     void Update ()
    22.     {
    23.  
    24.         anim.SetBool("Grounded", grounded);
    25.         anim.SetFloat("Speed", Mathf.Abs(Input.GetAxis("Horizontal")))
    26.  
    27.     }
    28.  
    29.     void FixedUpdate()
    30.     {
    31.         //Moving the player
    32.         float h = Input.GetAxis ("Horizontal");
    33.  
    34.         //Limiting the speed of the player
    35.         rb2d.AddForce ((Vector2.right * speed) * h);
    36.  
    37.         if(rb2d.velocity.x > maxSpeed)
    38.         {
    39.             rb2d.velocity = new Vector2 (maxSpeed, rb2d.velocity.y);
    40.         }
    41.  
    42.         if (rb2d.velocity.x < -maxSpeed)
    43.         {
    44.             rb2d.velocity = new Vector2 (-maxSpeed, rb2d.velocity.y);
    45.         }
    46.  
    47.     }
    48.  
    49. }
    50.  
     
  2. Trickzbunny

    Trickzbunny

    Joined:
    Jun 26, 2015
    Posts:
    64
    Windyone likes this.
  3. Windyone

    Windyone

    Joined:
    Nov 11, 2016
    Posts:
    8
    Thanks! Works Perfectly now! ;)