Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved "The type or namespace name 'input' could not be found (this part doesn't fit into the title)"

Discussion in 'Editor & General Support' started by Xamrey, Jun 18, 2021.

  1. Xamrey

    Xamrey

    Joined:
    Jun 14, 2021
    Posts:
    3
    Hi there,
    I'm new to unity and someone recently helped me fix an error in my code, but a new error came up. The error was: "The type or namespace name 'input' could not be found (are you missing a using directive or an assembly reference?)" I think it was talking about the "input.Dir.y" and "input.Dir.x"

    Code (csharp):
    1. void UpdateMovement()
    2.         {
    3.             Vector2 inputDir = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
    4.             input.Dir Normalize;
    5.  
    6.             Vector3 velocity = (transform.forward * input.Dir.y + transform.right * input.Dir.x) * walkSpeed;
    7.  
    8.             controller.Move(velocity * Time.deltaTime);
    9.         }
    Thanks in advance
     
  2. BABIA_GameStudio

    BABIA_GameStudio

    Joined:
    Mar 31, 2020
    Posts:
    497
    Code (csharp):
    1. input.Dir
    You named your variable (on line 3 in that code snippet) as
    inputDir
    , not
    input.Dir

    Change all the
    input.Dir
    to be the correct variable name
    inputDir

    Programming requires you to be exact with everything you do, so make sure you are typing everything correctly. You should also probably make good use of the beginner tutorials and the manual.[/code]
     
  3. As stated above. Also what is this?
    Do you want to normalize the inputDir or do you want to make another variable based on inputDir?
     
  4. Xamrey

    Xamrey

    Joined:
    Jun 14, 2021
    Posts:
    3
    Thanks, that did work but make another error, but I fixed it by removing the normalize part, even though now the player moves faster going sideways and forward/backward, it's better than having the error.