Search Unity

Question Enable/Disable a Script Component using Bolt

Discussion in 'Visual Scripting' started by Scrappbot, Jan 25, 2021.

  1. Scrappbot

    Scrappbot

    Joined:
    Jan 28, 2020
    Posts:
    10
    I'm trying to set up a Bolt Flow that will enable a script when the mouse goes over a game object (this script will outline the object and is named Outline). Whenever I try to set it up, no matter what I do, I get an error that it's missing a 'Target Object'. I just want to enable and disable the script. Please could anyone help?
    Here are some pictures for reference: enableFlow.PNG enableError.PNG
     
  2. Dudusstar

    Dudusstar

    Joined:
    Nov 19, 2020
    Posts:
    59
    Maybe you can put the script in a game object as a child of the parent and then set active game object to false in the child with the script.
     
  3. HoniGames

    HoniGames

    Joined:
    Aug 2, 2012
    Posts:
    23
    Connect it directly to the outline node, skipping the get component.
    The outline node should already be indicating the type of component with which you want to interact.
    On the other hand I don't know if on mouse over is the most appropriate since you are telling it in each frame to activate that component, maybe it would be better on mouse enter.
     
    Dudusstar likes this.
  4. dartekzgamez

    dartekzgamez

    Joined:
    Sep 12, 2022
    Posts:
    3
    anyone knows how to enable and disable ANY component of the game object in BOLT? for example to turn on-off a script (that must be directly on the gameobject)
     
  5. bilalakil

    bilalakil

    Joined:
    Jan 28, 2018
    Posts:
    77
  6. bilalakil

    bilalakil

    Joined:
    Jan 28, 2018
    Posts:
    77
  7. Welfarecheck

    Welfarecheck

    Joined:
    Jun 14, 2020
    Posts:
    120
    You can get any component with the get component type. In this example, I get the renderer for every enemy in the game and then disable the renderer if there is one anywhere on the object or its children.

    upload_2023-7-18_5-0-14.png
     
    dartekzgamez likes this.