im having a simple issue, tho im struggling to solve it, in my top down game, ive assigned a key to fire a bullet, however, when you press the key, it fires the gun even though the player does not have the gun,
i want something like when he has the gun and the fire key is press for the gun to fire and only fire when the player has it, not sure what do add in my condition,
You could use a boolean object variable. When the gun is not equipped the variable is false. When the player picks the gun up the variable is toggled to true and if the variable is true you can fire the gun.
At the beginning of the scene the object variable ‘fire’ of the gun-object is set to false. When the player collides with the gun the variable is toggled to true and this state is one of the conditions (together with mouse left click) to fire the gun. If the player drops the gun and it is in your level you need to toggle the variable back to false.