Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

A grid with Bolt ?

Discussion in 'Visual Scripting' started by Poolay, Sep 23, 2020.

  1. Poolay

    Poolay

    Joined:
    Mar 20, 2015
    Posts:
    6
    Hello Unity lovers,

    what is the best approach for you to generate at 8 x 8 grid size, like a chess board game for example ?

    I think we have many possibilities, it seems to be easy, but for artist like me, it's a little bit confuse.

    Love you o/

    Sev'
     
  2. michealcaj

    michealcaj

    Joined:
    Aug 18, 2017
    Posts:
    176
    Hello ,
    I suggest you design the grid lines in your 2d software and import the 2d sprite image into unity and finally create a material with the 2d image and add the material to a plane or quad
     
  3. Ex-Crow

    Ex-Crow

    Joined:
    Aug 14, 2020
    Posts:
    111
    Typically, you'd do this with a 2D array in C#. Bolt 1 doesn't handle arrays natively but there's a community made extension for multidimensional arrays in this link: https://github.com/LifeandStyleMedia/UAlive/releases/tag/1_3_1
    Import the package, then run Tools/Bolt/Build Unit Options. After that the multi array units should come up in search.

    But then he can't use it for gameplay, it's just visual. Or are you suggesting divorcing the visuals from the game systems completely?
     
    jeanpoolay and Poolay like this.
  4. michealcaj

    michealcaj

    Joined:
    Aug 18, 2017
    Posts:
    176
    Idk mate, I just suggested something I thought would be easier to get done...
    No offence mate
     
  5. sinjinn

    sinjinn

    Joined:
    Mar 31, 2019
    Posts:
    143
    public GameObject ChessSquare;
    for (x =1:x<9: x++)
    {
    for (y=1: y<9 = y++)
    {
    instantiate (ChessSquare, vector3(x,y,0), Qyarternion Identity);
    }}

    Somthing like this but with more experience and less bugs.
     
    Last edited: Oct 4, 2020
    Poolay likes this.
  6. Poolay

    Poolay

    Joined:
    Mar 20, 2015
    Posts:
    6
    it looks like an incantation :V but I understand the goal, I really love to try the same with bolt

    Others ideas ?

    (and thanks everybody o/)
     
  7. sinjinn

    sinjinn

    Joined:
    Mar 31, 2019
    Posts:
    143
    Yes. i felt the same way. I'm learning Bolt too, and it's much easier. I worked with the above equation before and was trying to firgure how to do it in Bolt, and it is so much clearer and easier to understand thanks to you asking this question. So here it is: Procedural Grid.jpg

    you can change the size by changing the "Last" values, and can plug in an "integer variable" for them to access them in the inspector. If you have more questions ill be happy to answer.
     
    Last edited: Oct 5, 2020
    Poolay likes this.
  8. sinjinn

    sinjinn

    Joined:
    Mar 31, 2019
    Posts:
    143
    what i get
     

    Attached Files:

  9. Poolay

    Poolay

    Joined:
    Mar 20, 2015
    Posts:
    6
    Marry me !!!
     
  10. sinjinn

    sinjinn

    Joined:
    Mar 31, 2019
    Posts:
    143
    Sorry, I am unfortunately attached.
     
    Blitz54 and Poolay like this.
  11. Poolay

    Poolay

    Joined:
    Mar 20, 2015
    Posts:
    6
    I confirm it works, you rox, next step : rename each grid cube instance with their initial X Y positions
     
  12. sinjinn

    sinjinn

    Joined:
    Mar 31, 2019
    Posts:
    143
    Oh jeez, that sounds complicated. Would you use Text Mesh Pro...how would you do that?

    Great idea.......How to execute? Let me talk to the rubber duck. Seems like we set the name of the instance after we create it. How do we set the name of an instance.....must search through integrated docs it seems....

    Another for loop....where to put it? add "Gameobject set name" unit after instantiate

    how to write name?
     
    Last edited: Oct 5, 2020
  13. Ex-Crow

    Ex-Crow

    Joined:
    Aug 14, 2020
    Posts:
    111
    This is why you need a 2D array from Jason's extension here which lets you get a grid cell based on X,Y position and then do whatever you need with it, including renaming.

    Getting started with Jason's Multi Array: https://lifeandstylemedia.com/docs/manual/entries/bolt/multiarray/GettingStarted.php

    Using Multi Array: https://lifeandstylemedia.com/docs/manual/entries/bolt/multiarray/UsingMultiArray.php

    Download here: https://github.com/LifeandStyleMedia/UAlive/releases/tag/1_3_1

    You'd then need to extend sinjinn's graph. Create a new 2D array before the for loops and add the instantiated grid cell to the created array so you can retrieve it later and do something with it.
     
    Last edited: Oct 5, 2020
    sinjinn and Poolay like this.
  14. Poolay

    Poolay

    Joined:
    Mar 20, 2015
    Posts:
    6
    Owwwkayyy,, I didn't think it was so complicated, i thought of a get name and set it with the X Y value.

    Maybe I 'll forget this kind of process.

    I really want to try your idea Ex-crow, I'll adding extension and see what happens. (do you have a powerful Graph image? )

    Byyye, lov' you guys \o/ ( Air check)
     
  15. sinjinn

    sinjinn

    Joined:
    Mar 31, 2019
    Posts:
    143
    thanks i will check this out.
     
  16. sinjinn

    sinjinn

    Joined:
    Mar 31, 2019
    Posts:
    143
    Hey, that seems like a great thing that I was not aware of. Do you know of any more similar Bolt related resources?
     
  17. Ex-Crow

    Ex-Crow

    Joined:
    Aug 14, 2020
    Posts:
    111
    Poolay likes this.
  18. sinjinn

    sinjinn

    Joined:
    Mar 31, 2019
    Posts:
    143
  19. dellahunti69

    dellahunti69

    Joined:
    Nov 16, 2020
    Posts:
    1
    The screenshot below shows code for generating a 3D array of game objects and renaming them according to their x,y,z values. Use String Literal nodes and add the index of each for loop to get the full name which is then set via Name(Set).

    Further off screen in the macro the new game objects are also stored into a two nested AotList. Using three List(Get) in a row (each one's int value set to the desired index) you can set your cursor to any one specific game object in the array. For example: List(Get) 1, List(Get) 7, List(Get) 4, would return the cube generated at 1,7,4 from the 3D list array.

    This code works the same for a 2D array, you just use one less for loop. Either way you don't need to use any other extensions. If you want to access the 3D array in other macros just save it as a variable with Variable(Set) and access it with Variable(Get). Easy Peasy.


    Unity.PNG
     
  20. Automageddon

    Automageddon

    Joined:
    Oct 31, 2016
    Posts:
    4
    I love Bolt but this is one of those cases where scripting is easier, even from a visual point of view.
    I was storing my grid as a list of vec2.
     
    myanko likes this.
unityunity