Search Unity

is there a way to do this

Discussion in 'Scripting' started by ThatOneCake, Sep 25, 2019.

  1. ThatOneCake

    ThatOneCake

    Joined:
    Dec 2, 2018
    Posts:
    36
    so i got a simple script


    if (Input.GetAxis("Fire1") = 1)
    {

    print("hello")

    }

    but unity says
    "Assets\movement.cs(22,13): error CS0131: The left-hand side of an assignment must be a variable, property or indexer"

    i just want to know if there is annyway to do this kind of script.
     
  2. Vharz

    Vharz

    Joined:
    Jul 28, 2012
    Posts:
    25
    It should be
    if (Input.GetButton("Fire1"))
    {
    }


    GetAxis is used for getting values such as mouse or controller thumbstick motion.

    You also have GetButtonDown, GetButtonUp etc.

    Also when comparing values in if statements use ==, not =.
    Use single = for assigning values only.
     
  3. ThatOneCake

    ThatOneCake

    Joined:
    Dec 2, 2018
    Posts:
    36
    thank you :D <3