Cant get input.getbuttondown to work correctly

Hello! I’m very new to scripting and I’m currently trying to learn inputs. I’ve been watching various videos but have been stuck on getting an input to work. Here’s the line of code that won’t work:

void Update ()
{
if (Input.GetButtonDown (“TO”))
Debug.Log (“Test!”);
}

That’s basically all the script. I left out the class and the first couple lines at the beginning, and to me it feels as thought this script should work fine. I’ve gone into Edit and changed the Input settings for TO, and I have bound it to r, but it wouldn’t read out in the console. So I tried starting a new project and now I have a compiler error “Input does not contain a definition for GetButtonDown”.

I have tried every solution I can think of! I hope you guys can help me sort this out!

PS If there are any awesome scripting videos I should check out, lemme know!

don’t do this, you’re assuming the problem is in the snippet you’ve provided and not elsewhere in the script, whilst at the same time saying you have no idea why its not working. Give us the entire script… and use code tags http://forum.unity3d.com/threads/using-code-tags-properly.143875/

Okay my bad! I wasn’t aware of the tag! I will include everything in my script, including my double slashes (I was using them for notes, so feel free to comment on them and make adjustments if I need to).

using UnityEngine;
using System.Collections;
using System;

public class Input : MonoBehaviour {

    //this function will use the method GetKey & GetButton
    //which will check if the player has pressed the key you detail

    //once they do, they will perfrom the action you specify

    //GetKey will search for a specific key and that key only

    //GetButton will search for a key that the user can specify in the console

    // Update is called once per frame

    void Update ()
    {
        if (Input.GetButtonDown ("TB"))
            Debug.Log ("Have a party!");
    }

The error about the non-existent method occurs because you’ve named your own class “Input”.
The Input class that you want to access belongs to the UnityEngine namespace, however, as your code belongs to your own class with that name, it will refer to that instead of using the UnityEngine.Input class.

Easiest solution: rename your class.

Thanks for your help!

No problem.

So does it still not recognize the input?

No your solution helped me and it now recognizes the input :slight_smile:

1 Like

I am having the same issue

5747053--604180--Capture.PNG

So do I, the error says ‘Input’ does not contain a definition for ‘GetDownButton’.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{

public float speed;
public float jump;

private float move;
private Rigidbody2D rb;

// Start is called before the first frame update
void Start()
{
rb = GetComponent();
}

// Update is called once per frame
void Update()
{
move = Input.GetAxisRaw(“Horizontal”);

rb.velocity = new Vector2(move * speed, rb.velocity.y);
if (Input.GetDownButton(“Jump”))
{
rb.AddForce(new Vector2(rb.velocity.x, jump));
}
}
}

It’s GetButtonDown, not GetDownButton.

Please always use code tags and please do not post in old threads. It’s always better to start a new one.

My problem was that i didnt put a mayus, im sooooooooooooo hapyyy}