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. Dismiss Notice

CS1022 Error

Discussion in 'Scripting' started by alpha1rider, Jan 20, 2021.

  1. alpha1rider

    alpha1rider

    Joined:
    Jan 11, 2021
    Posts:
    25
    Hi I am getting an error i.e CS1022
    Here is the script can you tell what is wrong with it
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.InputSystem;
    5. {
    6.  
    7. }
    8.  
    9. public class Playercontroller: MonoBehaviour
    10. {
    11.     private Rigidbody rb;
    12.     private float movementX;
    13.     private float movementY;
    14.  
    15.     // Start is called before the first frame update
    16.     void Start()
    17.     {
    18.         rb = GetComponent<Rigidbody>();
    19.     }
    20.  
    21.     void Onmove(InputValue movementValue)
    22.     {
    23.         Vector2 movementVector = movementValue.Get<Vector2>();
    24.  
    25.         movementX = movementVector.X;
    26.         movementY = movementVector.Y;
    27.     }
    28.  
    29.     void FixedUpdate()
    30.     {
    31.         Vector3 movement = new Vector3(movementX, 0.0f, movementY);
    32.  
    33.         rb.AddForce(movement);
    34.     }
    35. }
    36.  
     
  2. CatchFires

    CatchFires

    Joined:
    Jul 19, 2020
    Posts:
    38
    Yeah man, you have open/close brackets above your class just below your using statements
     
  3. alpha1rider

    alpha1rider

    Joined:
    Jan 11, 2021
    Posts:
    25
    Now what should I do
    I tried to delete them but it makes more errors
     
  4. CatchFires

    CatchFires

    Joined:
    Jul 19, 2020
    Posts:
    38
    Take them out
     
  5. alpha1rider

    alpha1rider

    Joined:
    Jan 11, 2021
    Posts:
    25
    I tried to delete them but it makes more errors
     
  6. alpha1rider

    alpha1rider

    Joined:
    Jan 11, 2021
    Posts:
    25
    It gives the error CS1061
    Here is the script after change
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using System.Diagnostics;
    4. using UnityEngine;
    5. using UnityEngine.InputSystem;
    6.  
    7. public  class Playercontroller : MonoBehaviour
    8. {
    9.     private Rigidbody rb;
    10.     private float movementX;
    11.     private float movementY;
    12.  
    13.     // Start is called before the first frame update
    14.     void Start()
    15.     {
    16.         rb = GetComponent<Rigidbody>();
    17.     }
    18.  
    19.     void Onmove(InputValue movementValue)
    20.     {
    21.         Vector2 movementVector = movementValue.Get<Vector2>();
    22.  
    23.         movementX = movementVector.X;
    24.         movementY = movementVector.Y;
    25.     }
    26.  
    27.     void FixedUpdate()
    28.     {
    29.         Vector3 movement = new Vector3(movementX, 0.0f, movementY);
    30.  
    31.         rb.AddForce(movement);
    32.     }
    33.  
    34.     private string GetDebuggerDisplay()
    35.     {
    36.         return ToString();
    37.     }
    38. }
    39.  
     
  7. CatchFires

    CatchFires

    Joined:
    Jul 19, 2020
    Posts:
    38
    What errors do you get after taking them out?
     
  8. alpha1rider

    alpha1rider

    Joined:
    Jan 11, 2021
    Posts:
    25
    It gives the error CS1061
    Here is the script
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using System.Diagnostics;
    4. using UnityEngine;
    5. using UnityEngine.InputSystem;
    6.  
    7. public  class Playercontroller : MonoBehaviour
    8. {
    9.     private Rigidbody rb;
    10.     private float movementX;
    11.     private float movementY;
    12.  
    13.     // Start is called before the first frame update
    14.     void Start()
    15.     {
    16.         rb = GetComponent<Rigidbody>();
    17.     }
    18.  
    19.     void Onmove(InputValue movementValue)
    20.     {
    21.         Vector2 movementVector = movementValue.Get<Vector2>();
    22.  
    23.         movementX = movementVector.X;
    24.         movementY = movementVector.Y;
    25.     }
    26.  
    27.     void FixedUpdate()
    28.     {
    29.         Vector3 movement = new Vector3(movementX, 0.0f, movementY);
    30.  
    31.         rb.AddForce(movement);
    32.     }
    33.  
    34.     private string GetDebuggerDisplay()
    35.     {
    36.         return ToString();
    37.     }
    38. }
    39.  
     
  9. CatchFires

    CatchFires

    Joined:
    Jul 19, 2020
    Posts:
    38
    That error means you're trying to use a method that doesn't exist, double click the error in your console, it should take you to the line that it's on, which line is it?
     
  10. alpha1rider

    alpha1rider

    Joined:
    Jan 11, 2021
    Posts:
    25
    I did something and the error was solved
    Thanks,Thanks,Thanks for your kind advice