I need to turn on and off object by Input.GetKey"…"
When I press “1” object is working, no error
When I press “2” object disables, no error
When I press “1” again, object doesn’t turn “on” and I see an error “Object reference not set up to an instance of an object” on the “SetActive(true);” line
The script is inside “Character” gameobject.
void Update ()
{
if(Input.GetKeyDown("1"))
GameObject.Find("Sword").SetActive(true);
else if (Input.GetKeyDown("2"))
GameObject.Find("Sword").SetActive(false);
}