How to switch between scripts on trigger?

I’m pretty new to C# so sorry if this is an easy script to figure out.

  • So I have a box collider on a cube, that when I shoot it with a projectile I want it to activate a power-up, which is another script. The original script is a click-and-shoot script, and the power-up script allows the player to click-and-hold to rapid fire. I know it has something to do with tags to trigger the script switch when a projectile hits it. I also wanted the power-up script to only last for a set amount of time before reverting back to the click-and-shoot script.

Any help would be much appreciated. :slight_smile:

I have couple of ideas how to make it:

  • Add your power-up script to player
    object at runtime: After detecting
    that cube was hit add to player
    object new component like this:

  • Active your power-up script which was preadded to player object in editor, after detecting that cube was hit grab reference to powerup script and do something like that mypowerUp.SetActive(true)