Hello. I am working on a game with more physics-based fighting, and wanted to try the new Input system- which is really not new anymore, but…
I have the input system for the player to have two different positive and negative bindings- one for the X Axis, and one for the Y axis. I would like to, for a test, have the player move left and right, swim down, and swim up or jump in the 2D water. At this stage, it doesn’t even move. FYI, speed = 10, and the PlayerController is actually the Input system. I have this in the Update() function. Movement is a Vector2.zero which is supposed to be the one that contains the values for the PlayerController to read.
PlayerController.ReadValue();
RB.velocity = new Vector2(movement.x * speed, movement.y * speed);
Again, this character does not budge. The rigidBody2D has a mass of 1, so it isn’t about that- I just switched it from its original number, which was 2. I checked and the everything is bound to the arrow keys. What am I missing here?
You read the value but don’t use it or cache it, so obviously it won’t work.
Also put the values in debug.logs to see what they are so you can understand your code better
I don’t have a character controller, it’s a rigidbody2d with an input system named PlayerController. As stated before, this has a LOT of physics. A character controller, I fear, won’t be enough.
I read the docs, and I don’t have a joystick or gamepad. I want to move with arrow keys, WASD, and space for a 2D platformer. I don’t know how to tell the device to use the actions for the basic movements.
Which Unity version do you use? If I update my project to the latest Unity and Input version I no longer get input for Vector2s, but it do work in previous versions. Could be related to this: What are the causes of these errors?
Movement isn’t thought of as a button, but a value. Specifically a vector 2 value. You can then use a composite binding for up/down/left/right to define WASD. You can also add gamepad and joystick to that action. This can all be done in the input action asset.
I suggest you follow a more recent tutorial on youtube. The Input system isn’t that hard to use, you just have to learn how it works a bit.