Search Unity

What can possibly be wrong with this code! (RESOLVED)

Discussion in 'Scripting' started by minecraftmonster340, Apr 28, 2018.

  1. minecraftmonster340

    minecraftmonster340

    Joined:
    Apr 28, 2018
    Posts:
    2
    I'm new to unity and don't understand all the syntax errors to C#, If anyone could read my code and the error and tell me what my problem is it would be greatly appreciated!

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3.  
    4. public class PlayerMovement : MonoBehaviour {
    5.  
    6.     public Rigidbody rb;
    7.     public float ForwardForce = 200;
    8.     public float RotationStyle = 1;
    9.  
    10.     // Update is called once per frame
    11.     void FixedUpdate () {
    12.  
    13.         //Makes ball roll forward
    14.         //If right Rotation
    15.         if (RotationStyle = 1)
    16.         {
    17.             rb.AddForce(-ForwardForce * Time.fixedDeltaTime, 0, 0);
    18.         }
    19.  
    20.         if (RotationStyle = 2)
    21.         {
    22.             rb.AddForce(ForwardForce * Time.fixedDeltaTime, 0, 0);
    23.         }
    24.  
    25.         if (RotationStyle = 3)
    26.         {
    27.             rb.AddForce(0, 0, -ForwardForce * Time.fixedDeltaTime);
    28.         }
    29.  
    30.         if (RotationStyle = 4)
    31.         {
    32.             rb.AddForce(0, 0, ForwardForce * Time.fixedDeltaTime);
    33.         }
    34.  
    35.     }
    36.  
    37.     //Check keys input
    38.     private void Update()
    39.     {
    40.  
    41.         Debug.Log(RotationStyle);
    42.  
    43.         if (Input.GetKey("w"))
    44.         {
    45.             RotationStyle = 1;
    46.         }
    47.  
    48.         if (Input.GetKey("s"))
    49.         {
    50.             RotationStyle = 2;
    51.         }
    52.  
    53.         if (Input.GetKey("a"))
    54.         {
    55.             RotationStyle = 3;
    56.         }
    57.  
    58.         if (Input.GetKey("d"))
    59.         {
    60.             RotationStyle = 4;
    61.         }
    62.  
    63.     }
    64.  
    65.  
    And the error is
    "Assets/PlayerMovement.cs(64,246): error CS1525: Unexpected symbol `end-of-file'" I do not see any unexpected symbol!
     
  2. Nlim

    Nlim

    Joined:
    Apr 23, 2018
    Posts:
    40
    You are missing a closing bracket } for
    1. public class PlayerMovement : MonoBehaviour {
    at the end of your file.
     
    Ryiah likes this.
  3. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    Ryiah likes this.