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.
Dismiss Notice
Join us now in the Performance Profiling Dev Blitz Day 2023 - Q&A forum where you can connect with our teams behind the Memory and CPU Profilers and the Frame Debugger.

Question Bolt - C# (switch) but naming is off and function might be wrong in bolt?

Discussion in 'Visual Scripting' started by Vaupell, Dec 29, 2020.

  1. Vaupell

    Vaupell

    Joined:
    Dec 2, 2013
    Posts:
    300
    I am trying hard to get it into the visual scripting, but i am simply not feeling it.
    Things that take me 5 minutes in C# takes me hours in Bolt, where as PlayMaker felt more "natural".

    Anyway, i got a AI working, and doing some things and trying to replicate my C# in bolt. (2 different project files)
    But as an example a problem i persistently run into is the naming of functions.

    Example, here i have a very simple switch.
    Code (CSharp):
    1.             switch (Activity)
    2.             {
    3.                 case "Idle":
    4.                     Energy = Energy - IdleCost;
    5.                     break;
    6.  
    7.                 case "Working":
    8.                     Energy = Energy - WorkCost;
    9.                     break;
    10.  
    11.                 case "Resting":
    12.                     Energy = Energy - RestCost;
    13.                     break;
    14.  
    15.                 case "Moving":
    16.                     Energy = Energy - MoveCost;
    17.                     break;
    18.  
    19.                 case "Eating":
    20.                     Food = Food - EatCost;
    21.                     break;
    22.  
    23.                 default:
    24.                     Energy = Energy - IdleCost;
    25.                     break;
    26.             }
    Here i am trying "switch" in bolt.


    It is CLEARLY not the same function as switch in C#
    So how on earth would i know what the functions are called with different naming convention?
     
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    1,116
    It is the same function, you just have to configure it in the Graph Inspector window. You can open it under Window/Graph Inspector.
     
    Dudusstar and Vaupell like this.
  3. guybro_thunderboots

    guybro_thunderboots

    Joined:
    Aug 27, 2015
    Posts:
    45
    Panthen has you covered for the general topic, but I thought I'd chime in on this bit:

    If you can confidently program in C#, I recommend viewing Bolt through the lens of it enabling you to make a "DSL" (domain specific language) for your game. That is to say, you can make high level nodes that represent high level actions in your game. Mimicking a C# structure/workflow in Bolt might not be particularly productive for you, especially if you're used to PlayMaker, which itself has a lot of high level actions like move camera, fade screen, etc.
     
    Vaupell likes this.
  4. ericb_unity

    ericb_unity

    Unity Technologies

    Joined:
    Nov 24, 2017
    Posts:
    167
    Like PanthenEye Said you can go in the graph inspector.
    SwitchCaseString.gif
     
    theor-unity likes this.
  5. Darkjollyminions

    Darkjollyminions

    Joined:
    Oct 10, 2020
    Posts:
    1
    Yes I have been wondering how bolt works, I think i might want to get into it for advanced things that I might not be able to do in C#.
     
    ericb_unity likes this.