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

Parsing errors ):

Discussion in 'Scripting' started by trashkevv, Dec 19, 2015.

  1. trashkevv

    trashkevv

    Joined:
    Dec 17, 2015
    Posts:
    2
    I'm very new to unity and c#
    I'm following this tutorial

    There are multiple errors and i really have no clue whats wrong...
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerMovement : MonoBehaviour {
    5.     public float moveSpeed;
    6.     public float jumpVelocity = 20;
    7.     public float RotationSpeed;
    8.     public float maxSlope = 60;
    9.     bool grounded = false;
    10.  
    11.  
    12.     void Update () {
    13.         transform.Translate (Input.GetAxis ("Horizontal") * Time.deltaTime * moveSpeed, 0f, Input.GetAxis ("Vertical") * Time.deltaTime * moveSpeed);
    14.         transform.Rotate (0f, (Input.GetAxis ("Mouse X") * RotationSpeed * Time.deltaTime), 0f, Space.World);
    15.  
    16.         if (Input.GetButtonDown ("jump") && grounded)
    17.             rigidbody.AddForce (0, jumpVelocity, 0);
    18. }
    19.     function OnCollisionStay (collision : Collision)
    20.     {
    21.         for (var contact : ContactPoints in collision.contacts)
    22.             {
    23.             if (Vector3.Angle(contact.normal,Vector3.up) < maxSlope)
    24.                     grounded = true;
    25.             }
    26.     }
    27. }
    28.  
    EDIT: I'm now realizing the tutorial is for javascript............
     
    Last edited: Dec 19, 2015
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    well the first clue is what the error messages say...
     
  3. trashkevv

    trashkevv

    Joined:
    Dec 17, 2015
    Posts:
    2
    @LeftyRighty
    Right sorry...
    1)Assets/Scripts/PlayerMovement.cs(19,35): error CS1041: Identifier expected
    2)Assets/Scripts/PlayerMovement.cs(21,34): error CS1525: Unexpected symbol `:', expecting `)', `,', `;', `[', or `='
    3)Assets/Scripts/PlayerMovement.cs(23,68): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
    4)Assets/Scripts/PlayerMovement.cs(23,68): error CS1525: Unexpected symbol `)', expecting `,', or `;'
    5)Assets/Scripts/PlayerMovement.cs(25,25): error CS1525: Unexpected symbol `}', expecting `,', or `;'
    6)Assets/Scripts/PlayerMovement.cs(28,1): error CS8025: Parsing error
    EDIT: I'm now realizing the tutorial is for javascript............
     
    Last edited: Dec 19, 2015
  4. frankrs

    frankrs

    Joined:
    Aug 29, 2009
    Posts:
    300
  5. frankrs

    frankrs

    Joined:
    Aug 29, 2009
    Posts:
    300
    1. if(Vector3.Angle(contact.normal,Vector3.up)< maxSlope)
    2. {
    3. grounded =true;
    4. }
    Im not sure if nesting the if statment is nessisary if your just doing one line of not
     
    Last edited: Dec 19, 2015
  6. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,732
    It's not necessary, but personally I usually do it, as it avoids bugs later on when extra code is added and I forget to add the curly braces at that point.
     
  7. frankrs

    frankrs

    Joined:
    Aug 29, 2009
    Posts:
    300
    Also in Unity 5 rigidbody is obsolete its get component<RigidBody>() now