Search Unity

Assets/Scripts/PlayerMotor.cs(8,22): error CS0246

Discussion in 'Scripting' started by Smol_1, May 17, 2022.

  1. Smol_1

    Smol_1

    Joined:
    Apr 26, 2021
    Posts:
    4
    I'm very new to scripting and I've been running into this problem,
    Assets/Scripts/PlayerMotor.cs(8,22): error CS0246: The type or namespace name 'crouching' could not be found (are you missing a using directive or an assembly reference?)
    I can't find a solution online. Any help would be appreciated. This is the code with the error. Screen Shot 2022-05-17 at 6.15.41 PM.png
     
  2. Johan_Liebert123

    Johan_Liebert123

    Joined:
    Apr 15, 2021
    Posts:
    474
    Firstly dont post ss's of code, its useless, copy and paste it into code tags, Secondly you can't declare 2 variables in the same line, first you declared a bool, then your using the crouching script as a reference on the same line, you gotta use 2
     
  3. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,929
    bool lerpCrouch ; crouching sprinting
    should probably be:

    Code (CSharp):
    1. bool lerpCrouching;
    2. bool crouching;
    3. bool sprinting;
    Or they can be declared all inline with:
    bool lerpCrouching, crouching, sprinting;
    .
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,742
    Are you interested in learning how to code? If so, remember: NOBODY here memorizes error codes. That's not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

    The complete error message contains everything you need to know to fix the error yourself.

    The important parts of the error message are:

    - the description of the error itself (google this; you are NEVER the first one!)
    - the file it occurred in (critical!)
    - the line number and character position (the two numbers in parentheses)
    - also possibly useful is the stack trace (all the lines of text in the lower console window)

    Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

    All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don't have to stop your progress and fiddle around with the forum.

    If you are only interested in having a good character controller, this is a much-more full-featured starter prototype FPS based on Character Controller (BasicFPCC):

    https://forum.unity.com/threads/a-basic-first-person-character-controller-for-prototyping.1169491/

    That one has run, walk, jump, slide, crouch... it's crazy-nutty!!