gameObject A detecting keyboard inputs from gameObject B.

Hi! I’m very new with unity. Been self studying the program for a week already.

I have

gameObject A

function Update () {

if(Input.GetButton("Fire1")){
renderer.enabled = true;

}

else {

renderer.enabled = false;

}

}

gameObject B

//I want to put a code here which will make gameObject B do something whenever it detects gameObject A inputting keyboard press such as Fire1. Thanks in advance!

Input.GetButton*() functions are not object specific. You can detect that specific button in any number of script. BTW, you probably what Input.GetButtonDown() in your code above. GetButtonDown() returns true for the single frame the button goes down. GetButton() returns true all the time the button is held donw.