Question by
igorjuszczak07 · Apr 12, 2020 at 01:04 PM ·
unity 2djump
Why does unity not detect any keys except "a" and "d"
I am following this https://www.youtube.com/watch?v=QGDeafTx5ug tutorial and Unity does not detect the "w" key being pressed, it detects "a" and "d" completely fine but it doesn't detect "W" or "space". here is my code:
public float speed;
public float jumpforce;
private float moveinput;
public Rigidbody2D rb;
private bool facingright = true;
private bool isgrounded;
public Transform groundcheck;
public float checkradius;
public LayerMask whatisground;
private int Jumps;
public int JumpsValue;
void start()
{
rb = GetComponent<Rigidbody2D>();
Jumps = JumpsValue;
}
void FixedUpdate()
{
moveinput = Input.GetAxis("Horizontal");
rb.velocity = new Vector2 (moveinput * speed, rb.velocity.y);
if (facingright == false && moveinput > 0)
{
flip();
}
else if (facingright == true && moveinput < 0)
{
flip();
}
isgrounded = Physics2D.OverlapCircle(groundcheck.position, checkradius, whatisground);
}
void update()
{
if (isgrounded == true)
{
Jumps = JumpsValue;
}
if (Input.GetKeyDown(KeyCode.W) && Jumps > 0)
{
Debug.Log("WHY AREN'T YOU JUMPING");
rb.velocity = Vector2.up * jumpforce;
Jumps--;
}
}
void flip()
{
facingright = !facingright;
Vector3 Scaler = transform.localScale;
Scaler.x *= -1;
transform.localScale = Scaler;
}
sorry about any grammar/spelling mistakes english isn't my first language
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612231207im_/https://answers.unity.com/themes/thub/images/avi.jpg)