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

how to fix my error

Discussion in 'Scripting' started by pinkpenguindev, Sep 3, 2020.

  1. pinkpenguindev

    pinkpenguindev

    Joined:
    Aug 13, 2020
    Posts:
    43
    Assets\movement.cs(30,25): error CS0117: 'KeyCode' does not contain a definition for 'a'

    my code
    if(Input.GetKey(KeyCode.a));
    {
    rb.AddForce(-500 * Time.deltaTime, 0, 0);
    }
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,697
  3. pinkpenguindev

    pinkpenguindev

    Joined:
    Aug 13, 2020
    Posts:
    43
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,697
    I know that. The link I shared contains an example of how to properly do what you're trying to do. Check the example code closely and find the difference between your code and the example code. The error message you're getting is telling you exactly what's wrong.
     
  5. pinkpenguindev

    pinkpenguindev

    Joined:
    Aug 13, 2020
    Posts:
    43
    it works but my code dose not work
     
  6. DaDonik

    DaDonik

    Joined:
    Jun 17, 2013
    Posts:
    258
    https://docs.unity3d.com/ScriptReference/KeyCode.html
    Scroll down to properties to see what is available and then change your code accordingly.

    If that still doesn't help you, either go to your local optician to get new glasses, or try something else than programming...
     
  7. pinkpenguindev

    pinkpenguindev

    Joined:
    Aug 13, 2020
    Posts:
    43
    it worked
     
    DaDonik likes this.
  8. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    185
    Well this hurt my brain