Activate a Object

I’m working on a top down game with a machine gun, and I was wondering how to make an object/cannon active when I walk to it and press the “F” button. Just like in “Skylanders” for Wii.

  • Felipe

I'm not sure what you means by activate. There is an activate boolean on avery GameObject, so you just need to get a reference to it and object.active = false / true, but it doesn't feel like that's what you mean (A deactivated object disable all it's components, thus is invisible).

Do you want to enable an AI script that makes an object perform some action ? Then when you press the F button from another script, do object.GetComponent().enabled = true;