Hi, does anyone know if there is a way to turn a script on or off like you can turn a component on or off. In my game the player collects a power up, and i would like the main player controller script to shut off for 30 seconds and the power up script to be active for the 30 seconds, giving the player a full auto gun, or a 3 round burst… It would be like selecting the check box while not in play mode, but i need that in a script. Does anyone know how I could do this in c# script? Thank you
scripts are just “components”
So would I make a new script with that Enable Component script? Or would I add the script to an existing script I have already?
You can if you want, but that sounds like overkill.
You would have to enable/disable a script from another script component.
You could do that with a script enable/disable, but if you’re just swapping weapons, probably a better way to do it where your one script just changes what it’s doing. Say a pistol does x damage and shoots at x speed, but then you get a machine gun that does more damage and shoots faster. You could modify the values or just change what happens when you hit your shoot button.
Other option is you have a weapon script attached to a weapon and depending on what weapon you pick up depends on how it responds.