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

Resolved Can you show game object on button press using bolt?

Discussion in 'Visual Scripting' started by jasonasaad2, Jan 19, 2021.

  1. jasonasaad2


    Nov 30, 2020
    Ok, I like visual scripting, I am not really good with C# and I tried but it failed.
    There isn't compiler errors, it just doesn't do anything

    Attached Files:

  2. mintman


    Nov 28, 2013
    I'm not exactly sure what the problem is, but there's a few things to check.

    First make sure the Flow Machine isn't on the object you want to activate.

    The object that runs the flow machine needs to be active. There is no way around this. This is the same for scripts that run any Unity lifecycle methods like
    . Start and Update in this flow machine won't be run if the object is off. If you haven't already, I'd suggest making a parent object or a sibling that only holds the flow machine.

    Decide between using a Coroutine or using syncronous code
    You're using
    with the coroutine flag checked on the unit. This is suspicious to me. This will start a coroutine every frame, which is unnecessary. If you plan to expand upon it and have some kind of sequential logic, you may have a real use case for a coroutine, but in that case I would probably choose to start it from the Start unit, and delete the duplicate.

    If you're not using a Coroutine, just set the values on Update
    It should look closer to the attached image. (I've mocked up a Super Unit to fit in for your call to GetButtonDown.)


    When making a loop, use a While Unit
    Bolt will stack overflow if you cycle flows as you have done in your attached image.

    If you are running a coroutine and you actually want an endless loop, then tie a Boolean Literal set to True to the input of a While Unit. You should only ever consider this on coroutines and ensure you have a "Wait" unit somewhere off of the While Unit. (eg. Wait Next Frame, Wait Until). Unity will lock if you don't, and you will feel a little bit bad every time it happens, but you'll recover.
    ericb_unity and Dudusstar like this.
  3. jasonasaad2


    Nov 30, 2020
    Yeah I was new to visual scripting, didn't know much, thanks for explaining all this