Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question: Multiple scripts on one object

Discussion in 'Scripting' started by MichaelTheAvali, Feb 28, 2020.

  1. MichaelTheAvali

    MichaelTheAvali

    Joined:
    May 10, 2017
    Posts:
    37
    I know unity can use multiple scripts on one object and I'd like to take advantage of this.
    I'm using the Invector Third Person Controller Lite and I'd like to make a script that temporally disables this controller when the player is hurt to apply knockback instead until they land.
    Would making a separate script work this way? Just asking in case the Invector Third Person Controller is too complex for me to make adjustments to
     
  2. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    Yes. find out what the script's type is, create public variable of that type so you can link it in editor, and then, when it's time to turn off the controller, simply use the enabled attribute for that script:
     
  3. MichaelTheAvali

    MichaelTheAvali

    Joined:
    May 10, 2017
    Posts:
    37
    Should be perfect, so basically
    When the player is damaged, disable controller and apply knockback to the rigidbody, then when the player is grounded, re-enable the controller
    that should be work, just been making sure that it wouldn't mess anything up