


According to the docs, FixedUpdate should be used instead of Update when dealing with a // Rigidbody. var keyboardSpeed = 20.0 // FixedUpdate is a built-in unity function that is called every fixed framerate frame. A higher value will // cause the object to move more rapidly. The horizontal speed of the keyboard controls. Ive tried modifying it and saying ridgidbody2d instead and some other stuff but it does not work. It says in the console log, that no ridgidbody is attached to my 2d player but the script is trying to acces the ridgidbody, and i use the 2d ridgidbody. But now there is a ridgidbody 2D feature, and that is the ridgidbody i use. But it does not work with the new update 4,3 with the 2d features.

The script is from 2010 and represents 2d movement. I know listening for keys and acting on them is probably more straight forward than this, but this has the benefit of updating keybindings much simpler in my opinion.I found this script on google, because there isn't many tutorials, im learning from the script itself. Once you have it installed, here's the quick start guide: Inputs Quick Start To use the new input system, you'll need to install the package and enable it: Input System Installation This lets you know if you are pressing a button to walk forward, backward, left, right, or some combination. In the example context.ReadValue() says to read the x,y coordinates of that action where x and y can be -1, 0, 1 (or any float in between). If the Vector2 is (0,0) do some other stuff that would likely be the character coming to a stopĬontext contains all kind of useful stuff, not just is a button pressed. If the Vector2 is not (0,0) do some movement stuff Pseudo code of your class: public void Move(InputAction.CallbackContext context) Then, when one of those bindings is triggered a specific function in your script can be triggered.

With the new system, you create an action and assign as many bindings to it as you want. I don't know about for 2D, but in 3D I've been using the new inputs feature with callbacks instead of listening for keycodes manually.
