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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Visual scripting in Unity

Discussion in 'General Discussion' started by kikoman, Mar 19, 2015.

  1. Jerementor

    Jerementor

    Joined:
    Apr 17, 2012
    Posts:
    10
    Can you use Blox2 for 2D in unity?
     
  2. shadowninjapie

    shadowninjapie

    Joined:
    May 22, 2015
    Posts:
    9
    ive never used visual scripting but seems interesting. i tried antares universe but it seemed like it was basically just the exact same as coding except u use blocks instead of text since all the blocks were actually unity methods.
     
  3. rahuxx

    rahuxx

    Joined:
    May 8, 2009
    Posts:
    537
    Agree to Shadowninjapie, but do you know that a picture teaches more then simple text? We non programmer do not know how to read the code but the VS gives us readability of code being a picture /block.
     
  4. toddheilmann

    toddheilmann

    Joined:
    Dec 25, 2013
    Posts:
    13
    I would imagine blox2 would work for 2d. The dev posted he's going to be out of contact some this week. So you might pose your question at his forum then..
     
  5. Disruptive-sw

    Disruptive-sw

    Joined:
    Oct 8, 2014
    Posts:
    32
  6. rahuxx

    rahuxx

    Joined:
    May 8, 2009
    Posts:
    537
    Just grab codes from both live training and the iCS forum. Can not stop my self from saying both codes looks very similar. Check your self for the Gama Manager - GM

    Here is code for GM from iCS forum.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using iCanScript.Variables;
    4.  
    5. namespace iCanScriptExamples.BreakOut {
    6.  
    7.     public class BreakOutGM : MonoBehaviour {
    8.         // =============================================================
    9.         // PUBLIC FIELDS
    10.         // -------------------------------------------------------------
    11.         public  Int lives=  new Int(3);
    12.         public  Int bricks=  new Int(20);
    13.         public  Text livesText= default(Text);
    14.         public  GameObject gameOverText= default(GameObject);
    15.         public  GameObject youWonText= default(GameObject);
    16.         public  Object bricksPrefab= default(Object);
    17.         public  Object deathParticles= default(Object);
    18.         public  Object paddlePrefab= default(Object);
    19.  
    20.         // =============================================================
    21.         // PRIVATE FIELDS
    22.         // -------------------------------------------------------------
    23.         private  GameObject p_clonePaddle= default(GameObject);
    24.  
    25.  
    26.         // =============================================================
    27.         // PUBLIC FUNCTIONS
    28.         // -------------------------------------------------------------
    29.  
    30.         // -------------------------------------------------------------
    31.         /// Initialize the scene on script wakeup.
    32.         public  void Awake() {
    33.             SetUp();
    34.         }
    35.  
    36.         // -------------------------------------------------------------
    37.         /// Setup the initial position of the paddle and bircks.
    38.         public  void SetUp() {
    39.             SetuPaddle();
    40.             Instantiate(bricksPrefab, transform.position, Quaternion.identity);
    41.         }
    42.  
    43.         // -------------------------------------------------------------
    44.         /// Performs a countdown of the number of bricks and
    45.         /// verifies the game over conditions.
    46.         public  void DestroyBricks() {
    47.             bricks.SubAndUpdate(1);
    48.             CheckGameOver();
    49.         }
    50.  
    51.         // -------------------------------------------------------------
    52.         /// The player loses one life and the game over conditions are
    53.         /// verified.
    54.         public  void LoseLives() {
    55.             livesText.text= "Lives : " + lives.SubAndUpdate(1);
    56.             Instantiate(deathParticles, p_clonePaddle.transform.position, Quaternion.identity);
    57.             Destroy(p_clonePaddle);
    58.             Invoke("SetuPaddle", 1f);
    59.             CheckGameOver();
    60.         }
    61.  
    62.         // -------------------------------------------------------------
    63.         /// Compares the number of lives and the number of remaining
    64.         /// bricks to determine if a game over conditions have occured.
    65.         ///
    66.         /// The player wins if no bricks remain and loses if he/she has
    67.         /// no lives left.
    68.         public  void CheckGameOver() {
    69.             if(lives < 1) {
    70.                 gameOverText.SetActive(true);
    71.                 Time.timeScale= 0.25f;
    72.                 Invoke("Reset", 1f);
    73.             }
    74.             if(bricks < 1) {
    75.                 youWonText.SetActive(true);
    76.                 Time.timeScale= 0.25f;
    77.                 Invoke("Reset", 1f);
    78.             }
    79.         }
    80.  
    81.         // -------------------------------------------------------------
    82.         /// Reloads the level after a game over has been declared.
    83.         public  void Reset() {
    84.             Time.timeScale= 1f;
    85.             Application.LoadLevel(Application.loadedLevel);
    86.         }
    87.  
    88.         // -------------------------------------------------------------
    89.         /// Initializes the position of the paddle and the ball.
    90.         public  void SetuPaddle() {
    91.             p_clonePaddle= Instantiate(paddlePrefab, transform.position, Quaternion.identity) as GameObject;
    92.         }
    93.     }
    94. }
    Here is code for GM from live training -

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4.  
    5. public class GM : MonoBehaviour {
    6.  
    7.     public int lives = 3;
    8.     public int bricks = 20;
    9.     public float resetDelay = 1f;
    10.     public Text livesText;
    11.     public GameObject gameOver;
    12.     public GameObject youWon;
    13.     public GameObject bricksPrefab;
    14.     public GameObject paddle;
    15.     public GameObject deathParticles;
    16.     public static GM instance = null;
    17.  
    18.     private GameObject clonePaddle;
    19.  
    20.     // Use this for initialization
    21.     void Awake ()
    22.     {
    23.         if (instance == null)
    24.             instance = this;
    25.         else if (instance != this)
    26.             Destroy (gameObject);
    27.  
    28.         Setup();
    29.    
    30.     }
    31.  
    32.     public void Setup()
    33.     {
    34.         clonePaddle = Instantiate(paddle, transform.position, Quaternion.identity) as GameObject;
    35.         Instantiate(bricksPrefab, transform.position, Quaternion.identity);
    36.     }
    37.  
    38.     void CheckGameOver()
    39.     {
    40.         if (bricks < 1)
    41.         {
    42.             youWon.SetActive(true);
    43.             Time.timeScale = .25f;
    44.             Invoke ("Reset", resetDelay);
    45.         }
    46.  
    47.         if (lives < 1)
    48.         {
    49.             gameOver.SetActive(true);
    50.             Time.timeScale = .25f;
    51.             Invoke ("Reset", resetDelay);
    52.         }
    53.  
    54.     }
    55.  
    56.     void Reset()
    57.     {
    58.         Time.timeScale = 1f;
    59.         Application.LoadLevel(Application.loadedLevel);
    60.     }
    61.    
    62.     public void LoseLife()
    63.     {
    64.         lives--;
    65.         livesText.text = "Lives: " + lives;
    66.         Instantiate(deathParticles, clonePaddle.transform.position, Quaternion.identity);
    67.         Destroy(clonePaddle);
    68.         Invoke ("SetupPaddle", resetDelay);
    69.         CheckGameOver();
    70.     }
    71.  
    72.     void SetupPaddle()
    73.     {
    74.         clonePaddle = Instantiate(paddle, transform.position, Quaternion.identity) as GameObject;
    75.     }
    76.  
    77.     public void DestroyBrick()
    78.     {
    79.         bricks--;
    80.         CheckGameOver();
    81.     }
    82. }
    iCS2 is still in development and if it keeps going like this then those who knows programming will also like to use it for sure.
     
  7. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    Yes, there is support for the classes in Unity related to 2D. Please use my support forum for questions about Blox 2.
     
  8. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,363
    I am having a go writing my own visual scripter for Unity. It's quite an interesting challenge of trying to get something that feels intuitive but still has the same power as scripting. So I'm keeping an eye on this thread.

    For example having a variable "x" in script is simple and can be used multiple times. But in visual scripting you might end up with hundreds of wires leading off to this x.

    A similar challenge from maths was to find a visual representation of tensor notation. (See Penrose notation). But it never really took off. It just seems that human-like language is the best way to give instructions to a computer for the most part. Imagine forcing someone to write a novel with a visual language system!

    But my favourite one is scratch. It is not so powerful but very easy.
     
  9. Rixtter

    Rixtter

    Joined:
    Mar 31, 2014
    Posts:
    242
    Good luck with your project, you have HUGE competition but you'll get a fair audience ;-)

    I retract my beef with the dev Leslie from Blox2, he PM'd me to genuinely apologise for not answering my posts - he even offered me a refund (which I didn't take) since I've now moved on to iCanScript.

    Really, it's personal choice for many reasons. If you like Scratch yoonitee, I read Blocky is the same thing... and Blox2 although coded independently... is extremely similar.

    I went iCS because it doesn't suffer any of the usual VS shortcomings... mainly target devices & asset dependency... u can literally create the C# and delete iCS afterwards. The devs portfolio is also amazing, this dude is a rock star in development circles... take a look at the Introductions section ;)
     
  10. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,363
    Thanks, I'm just doing it for fun because I like messing around with that sort of thing. It might never turn into anything.

    Also, I am interested in what could be done with Unity and Cortana in Windows 10! So not only visual scripting but then you might have auditory scripting:

    e.g. "Cortana, open Unity, add my alien mesh from Blender and add a red material."

    I wonder how much could be done that way. It might be more suited to visual scripting: "Cortana, connect node x to node y". etc.
     
  11. rahuxx

    rahuxx

    Joined:
    May 8, 2009
    Posts:
    537
    Your dream is really big but it is being seen in the world where people don't even accept the concept of simple Visual Scripting.
     
  12. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    Visual scripting is like a collection of macros, right? If you made a well named library of functions, you'd have the coding equivalent of visual scripting.
     
    GarBenjamin likes this.
  13. Disruptive-sw

    Disruptive-sw

    Joined:
    Oct 8, 2014
    Posts:
    32
    The VS product have different views and directions.

    Some do work from a set of library components while other implement a structure concept such an FSM or behaviour tree while others address a more general programming solution. In some cases, these can be integrated to offer a more complete solution. It is difficult to put every VS solution in the same bag.
     
    Tomnnn and rahuxx like this.
  14. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    I understand, I did buy playmaker for that reason lol. I studied to it get a working example of how to make a statemachine. The projects run well for having multiple folders with thousands of scripts each, each one doing only 1 function. That's the highest level of cohesion I've ever seen.
     
    Disruptive-sw likes this.
  15. Tropobor

    Tropobor

    Joined:
    Mar 24, 2014
    Posts:
    73
    Maybe out of context ... but why no one speaks of {b} Behaviour Machine, down here?
    Too... discreet ??
     
  16. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    Same question for why I didn't much mention of Universe.
     
    Last edited: Jun 5, 2015
  17. Rixtter

    Rixtter

    Joined:
    Mar 31, 2014
    Posts:
    242
    I have the Indie version. Excellent tool, but the support forum has all but dried up. The Pro version gives the much-needed AI nodes, but a huge jump in price to acquire it. I asked Anderson if he would consider packaging the AI by itself, or reduce the cost because comparable systems can provide the same for much less. He hasn't replied in the past few weeks, hopefully he hasn't given up & is working on something...
     
  18. bravo075

    bravo075

    Joined:
    Dec 7, 2012
    Posts:
    32
    Agreed, I would prefer to dig into UE4's C++ than the blueprint system, but most of their docs and tutorials are oriented towards blueprints. Unity on the other hand has Mono and will have .NET 4.6 support which I really like, I hope their new visual scripting won't screw up their support for .NET tools.
     
  19. juan-jo

    juan-jo

    Joined:
    May 15, 2010
    Posts:
    162
    Too many prejudices around graphic scripting.
    Antares Universe was a good system, somewhat cumbersome but as powerful as text coding (yes, it is possible and there are other cases) but now it is defunct.
    I hope that Unity will make a good native graphic system soon.
    And then I hope text coding people will let us live with our visual extravagance.