Search Unity

Simple movements doesn't work in the beta

Discussion in '2019.3 Beta' started by ngomes007, Oct 13, 2019 at 1:13 AM.

  1. ngomes007

    ngomes007

    Joined:
    Nov 19, 2017
    Posts:
    6
    I coded simple movements and it said doesn't match name..
    Same file worked with 2019.1
    Does someone know why
    using System.Collections.Generic;
    using UnityEngine;

    public class charactercontrol : MonoBehaviour {
    public float speed = 10.0F;
    // Use this for initialization
    void Start () {
    Cursor.lockState = CursorLockMode.Locked;
    }

    // Update is called once per frame
    void Update () {
    float translation = Input.GetAxis ("Vertical") * speed;
    float straffe = Input.GetAxis ("Horizontal") * speed;
    translation *= Time.deltaTime;
    straffe *= Time.deltaTime;

    transform.Translate(straffe, 0, translation);

    if (Input.GetKeyDown ("escaps"))
    Cursor.lockState = CursorLockMode.None;

    }
    }
     
  2. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    4,118
    Please post the exact error message the next time and please edit your post to use code tags.

    I tested it with Untiy 2019.1.14f1 and it outputs "ArgumentException: Input Key named: escaps is unknown" there too.

    "escaps" is not a valid key identifier for
    GetKeyDown
    , you should take a look at the documentation:
    https://docs.unity3d.com/ScriptReference/Input.GetKeyDown.html

    Supported key identifiers are listed at the bottom of this page:
    https://docs.unity3d.com/Manual/ConventionalGameInput.html

    You probably meant "escape" instead. However, you could also use the
    KeyCode
    enum instead, which gives a compile rather then runtime error, thus not as easy to make such mistake:
    Code (CSharp):
    1. if (Input.GetKeyDown(KeyCode.Escape))
    https://docs.unity3d.com/ScriptReference/KeyCode.html
     
    LeonhardP and vakabaka like this.