Master Grid Placement in Unity 2022 P1 - Calculating Cell Position

Поділитися
Вставка
  • Опубліковано 21 лис 2024

КОМЕНТАРІ • 308

  • @SunnyValleyStudio
    @SunnyValleyStudio  Рік тому +5

    Part 2 about grid visualization -> ua-cam.com/video/nKF4Pwb-6Ow/v-deo.html

  • @JB_101
    @JB_101 4 місяці тому +3

    I love your passion for what the majority see as impossibly dull! I code for a living and for a hobby! Just trying to learn Unity now! 🙂

  • @XconeArtist
    @XconeArtist 12 днів тому +1

    You got great pacing. Enough details for me to learn, but not too much detail to get bored. I enjoyed watching this. Thanks 👍

    • @SunnyValleyStudio
      @SunnyValleyStudio  10 днів тому

      I'm glad that you like it and I really appreciate your comment 🙂

  • @IgnacioEsteves
    @IgnacioEsteves Місяць тому +1

    This might be, hands down, the best tutorial I've ever seen in my life. Not even joking, you have too much talent!

  • @flatcoaster
    @flatcoaster Рік тому +5

    I've never thought to use the Unity Grid component all this long... seems very useful now

  • @rongreen385
    @rongreen385 Рік тому +12

    I wasn't having much luck finding good examples of using Unity's Grid class and along comes your tutorial - yay! Thank you so much.

  • @de_w0r
    @de_w0r Рік тому

    Thank you! I'm not a native british or american, but i understood all frazes or words. My english level not low, and not high.
    The most best part of your tutorial is code. U make code so easy that hard to didn't undrestand what happen in video.
    One more - Thank you! +rep

  • @frmlsshrmn
    @frmlsshrmn Рік тому +6

    This is extremely useful. I've been trying to get started on a base-building game and what I want to accomplish first is to make it possible to plop down objects (buildings) of various dimensions (1x1, 2x3) on a grid. So I'm looking forward to the rest of the series. Thanks!

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому +1

      Awesome! I will be posting the remining parts this week.

    • @MuhammadBilal-cs3dg
      @MuhammadBilal-cs3dg Рік тому

      @@SunnyValleyStudio can you please share the starter project link

  • @scjohnson243
    @scjohnson243 Рік тому +2

    Really useful, been trying to follow one of these and have not had much luck, so far this one is great!

  • @ianfavreau9776
    @ianfavreau9776 9 місяців тому +2

    To anyone having trouble with the Mouse Indicator Testing part, make sure you have a mesh collider on the plane you are using as your grid.
    Also, to anyone having trouble with the Cursor Indicator not aligning with the cursor, make sure it has the correct Y position as it is different in the game than in the scene viewport. Spend time to make sure it is perfectly level in the game when you hit play (it doesn't matter if it is below the plane in the scene mode).

  • @wasifalmeem4651
    @wasifalmeem4651 Рік тому +2

    Thanks a lot, really simple and straight forward. used prebuild unity components with a really simple logic. Thanks a lot brother

  • @opponentbacon
    @opponentbacon 5 місяців тому +1

    SUCH an amazing set of tutorials and like other people have also said; exactly what i was looking for. thank you so much !

  • @GocoYT
    @GocoYT 6 днів тому +1

    Great straight forward tutorial! Love the stuff! :)

  • @Chigamungus
    @Chigamungus 9 місяців тому +1

    Fantastic tutorial! Exactly the kinds of things I was hoping to learn

  • @FrogKin9
    @FrogKin9 Рік тому +1

    Thank you - again...
    Great work and alyways exactly what I'm looking for.
    As soon as I (or if I ever) earn some money with my Games, I will support you financially as well.

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому +1

      Thanks. And be sure to focused on making games first 👍 Making money from games is kind of separate skill and I don't think it is easy to learn it and make games at the same time 🙂

  • @zeggxr1539
    @zeggxr1539 Рік тому +2

    really excited to watch it, thanks for the great tutorials!!

  • @bane9109
    @bane9109 Рік тому +1

    Hey Peter, thanks for this tutorial! Grid system is something i’ve had trouble with in the past, so I’m looking forward to learning how to implement this

  • @jessepaulsen973
    @jessepaulsen973 Рік тому +1

    Great vid. By the way this creator also has courses on Udemy. Several of the courses are great for people who have got the fundamentals of Unity and coding under their belt and need to start learning architecture, design patterns and internal testing.

  • @BlueDuck-vv3eu
    @BlueDuck-vv3eu Місяць тому +1

    Thanks! I like this to the point style of teaching that you do.

  • @Berndr
    @Berndr Рік тому +1

    Really great and clear strait forward explanation!

  • @yuhochih
    @yuhochih 10 місяців тому +1

    Thank you for making this tutorial, it is really helpful to me

  • @clintonhamil9371
    @clintonhamil9371 10 місяців тому +1

    Thanks! Using this in a Game Jam build right now :D

  • @Lazzarus7
    @Lazzarus7 5 місяців тому +1

    Nice tutorial, very well explained!

  • @This-Was-Sparta
    @This-Was-Sparta Рік тому +4

    Great stuff as always. Exactly what I was looking for.

  • @hbcck
    @hbcck Рік тому +1

    A very clear and entertaining video.

  • @RavenG102
    @RavenG102 Рік тому +1

    its a good start for my ideas, thanks!

  • @КириллКурлянов-ф2й

    Thank's man. That just what I've been looking for

  • @gabrielzanoni9961
    @gabrielzanoni9961 Рік тому +1

    Thank you very much! You teaching skills are awesome!

  • @ender_0967
    @ender_0967 Рік тому +2

    ❤ Thanks Peter, this tutorial is fantastic, It helped a lot!

  • @mcredbunny5542
    @mcredbunny5542 10 місяців тому +1

    Thanks for the tutorial but where is the project you mentioned at the start of the video?

    • @SunnyValleyStudio
      @SunnyValleyStudio  10 місяців тому

      If you mean the extended version you can find it here courses.sunnyvalleystudio.com/ . Thanks for your support! 😍

  • @troyna77
    @troyna77 Рік тому +1

    thanks a lot !!! i always learn when watching you tutorials. I really enjoy your udemy courses.

  • @hadiseylani2265
    @hadiseylani2265 5 місяців тому +1

    awsome tutorial... thanks for your clear explanations

  •  Рік тому +1

    Your videos are amazing please share more video 😊😊😊😊😊😊😊😊

  • @vvbgamedevx11
    @vvbgamedevx11 8 місяців тому +1

    Thanks for the tutorial looking for something like this....

  • @Joseph-ud1sd
    @Joseph-ud1sd Рік тому +1

    This Video helped me a lot! Thank you!

  • @richiebee33
    @richiebee33 6 місяців тому

    Just what the doctor ordered! I can't wait to use this in the game. I'll definitely be buying your course. One question: my game is currently using Unity 2021. Is it a must to upgrade to 2022?

    • @SunnyValleyStudio
      @SunnyValleyStudio  6 місяців тому +1

      As long as you are using Unity 2021.2 and above there should be no issues. This is because I am using C#9 features docs.unity3d.com/2021.2/Documentation/Manual/CSharpCompiler.html
      I am not sure about the shader part since this changes a lot (we are using a shader graph). But its something that you can convert easily - well you would recreate the shader in the older version of shader graph if it doesn't work out of the box).
      So those are the only limitations that comes to mind.

  • @starfart69
    @starfart69 Рік тому +1

    When you say you can change it to hexagon in @7:15, it would be so much better to watch if you click it just to show the viewer what changes if you do that.

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому +1

      Thanks for the feedback! 👍

    • @starfart69
      @starfart69 Рік тому

      @@SunnyValleyStudio Hey, you have great content man. Your subs are criminally underrated.

  • @eldarkvadrat
    @eldarkvadrat Рік тому

    You doing good job via tutorials. Glad to watch it :)

  • @mezainab848
    @mezainab848 Рік тому +1

    amazing and easy tutorials

  • @deibysantiago9639
    @deibysantiago9639 Рік тому +1

    thank you sunny, amazing tuts

  • @ZiKsor
    @ZiKsor 4 місяці тому

    Hi, your guide is very useful, but can you tell me how to create a Coursorindicator prefab?

  • @Tozerus1
    @Tozerus1 Рік тому +1

    Thank you for the great tutorial!

  • @minhquandam7334
    @minhquandam7334 Рік тому +1

    You are my savior !!! Thanks for the video

  • @ItsPBUH
    @ItsPBUH Рік тому +1

    These are great tutorials, always love your content :)

  • @강승우-p5z
    @강승우-p5z Рік тому +2

    I`m trying to adapt your lecture for 2D Unity System. This lecture is so perfect for me and your last explanation for pivot makes me know why my tilemap dislocated little. Thank you. Let me ask you one more question... I think I can alternate Grid Component to Tilemap Component because we usually use it in 2D unity, and it is OK until but... do you think is there potential problems?

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому +1

      Hey! Tilemap in unity either inherits or uses grid component. I think it uses it because you get the grid component added whenever you create a tilemap. I think you can use either one.

  • @jeremylock199
    @jeremylock199 Рік тому

    Thanks a lot for this Peter. I really want a grid building system for my tank game (actually using your tutorial for that too). I want to reimagine the game Bolo on the Apple II.

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      Sounds awesome! Be sure to share your progress on SVS discord (link in every video) 🙂

    • @MuhammadBilal-cs3dg
      @MuhammadBilal-cs3dg Рік тому

      @@SunnyValleyStudio can you please share the starter project link

  • @CLAREBPED
    @CLAREBPED Рік тому +1

    esse curso me ajuda muito com meus estudos, obrigado!

  • @WEB2TV
    @WEB2TV Рік тому

    This is wonderful tutorial! Thank you!!

  • @dukemagus
    @dukemagus Рік тому

    That's a good tutorial. Do you make guides for different engines or it's an Unity-focused channel??

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      Hey!
      Right now (this channel) is Unity focused. I want to do something similar for Godot in the near future. No plans for other engines though 🙂
      BTW many people have mentioned that some of the Procedural generation tutorials of mine are easily portable to Unreal engine. Code logic / architecture can easily be reused between engines. Things like Unity specific components (like the Grid component here) might be harder to translate though.

  • @aciloaicilo2926
    @aciloaicilo2926 Рік тому +1

    really helpful video, thanks

  • @farvardinmainyu1961
    @farvardinmainyu1961 Рік тому +1

    Thank you Peter !

  • @zubairGamX
    @zubairGamX Рік тому +1

    Just Amazing Sir

  • @emmanuelavanzi3998
    @emmanuelavanzi3998 4 місяці тому +1

    nice tutorial thank you

  • @mikeaelmich
    @mikeaelmich Рік тому +1

    Maybe you have tutorial on generating a house based on outlines on a satellite map. So that users can draw the shape of their house and apply extrude

  • @ShahanAkhter
    @ShahanAkhter Рік тому +1

    thanks awesome tutorial

  • @ranggasukandar3533
    @ranggasukandar3533 Рік тому

    Thanks! super easy to understand👍

  • @cl2401
    @cl2401 2 місяці тому +1

    really helpful video

  • @graheet
    @graheet Рік тому

    You wonderful man. Thank you very much.

  • @Cortanuh
    @Cortanuh 10 місяців тому +1

    Thanks for the video :)

  • @heiswatchingus
    @heiswatchingus Рік тому

    After this tutorial I'll be a phucking billionare!

  • @사쿠노
    @사쿠노 Рік тому +1

    감사합니다.

  • @muhammadammarr2796
    @muhammadammarr2796 Місяць тому +1

    Thanks for this awesome tutorial!
    but I have question, I had already watched all of the series. when I place the object with say 3x2, cursor (that take first grid with mouse cursor) already aligned with grid that has placement layer mask. But for the rest generated cursor still can place outside the grid boundaries
    how can I fix this or am I missing something?

    • @SunnyValleyStudio
      @SunnyValleyStudio  Місяць тому +1

      You mean you would like to add Bounds to the placement area? I cover it in my paid project. Basically you need to check if each tile that your 3x2 area requires for placement is inside the bounds that you define. I do this check when we move the cursor and update the preview. Again I don't cover this in my free implementation. Sorry

    • @muhammadammarr2796
      @muhammadammarr2796 Місяць тому

      @@SunnyValleyStudio it's okay
      again thanks for sharing :D

  • @jennih835
    @jennih835 Місяць тому +1

    Nice, Thanks!

  • @jaybehl7567
    @jaybehl7567 Рік тому +3

    Hi, when I import the project assets (i only import the ones needed for the prefabs) the "CursorIndicatorParent" only shows as a opaque blank white square. It doesnt have the transparent hole in the center it does like yours. I am using Unity 2022.3.0. Can u help me? Otherwise, fantastic tutorial!

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      Maybe you have to set the "Render Mode" to be Transparent in the Material for the Cursor object docs.unity3d.com/Manual/StandardShaderMaterialParameterAlbedoColor.html

    • @danieletacconi5140
      @danieletacconi5140 11 місяців тому

      @@SunnyValleyStudio
      Ti sto seguendo ora e se permetti provo a aiutare riguardo alla domanda anche se nella mia lingua.
      Seleziona il materiale cellIndicator, in alto a destra cambia lo shader in standard. A questo punto doce c'è albedo ci metti lo sprite GridInidcator che trovi nella cartella _content. Fatto ciò basta che rimetti lo shader in sprites/default e dovresti visualizzare perbene. Ottimo video

  • @TheAlliones
    @TheAlliones Рік тому +1

    Great Video!

  • @back2back712
    @back2back712 7 місяців тому +1

    thank you sooooo much big brother

  • @Aushin510
    @Aushin510 10 місяців тому +1

    Hello, I am having issues with the grid being unaligned and unaffected by any changes to dragging the GridParent around. I am using the Voxel Generator tutorial you made and trying to implement this building grid system in a 3D world. I tried to follow along perfectly (swapping the floor grid indicator for a 3D visual model) but the closest i ever got to a functional (somewhat buggy) 3D grid is this:
    private void Update()
    {
    Vector3 mousePosition = inputManager.GetSelectedMapPosition();
    Vector3 gridPosition = new Vector3(Mathf.Round(mousePosition.x), Mathf.Round(mousePosition.y), Mathf.Round(mousePosition.z));
    mouseIndicator.transform.position = mousePosition;
    cellIndicator.transform.position = gridPosition;
    }
    With the GridParent Transformed to -.5 on XYZ. Depending on the face of the voxel, it either works correctly or places the grid cursor in the air beside the target block. Any help to my confusion is appreciated!

    • @SunnyValleyStudio
      @SunnyValleyStudio  10 місяців тому

      I am not sure but it might be but remember that the Grid component has center points in the bottom-left corner (at least in 2D). Maybe it is a matter of math - that in the voxel generator the center point is in the middle of the voxel. Maybe just adding an offset of -.5 to x and z by default would fix that?
      The error sounds like a floating point issue where since it it is on the edge of 2 grid tiles it sometimes works and sometimes doesn't, Still might be some more complex problem.

  • @bluzenkk
    @bluzenkk Рік тому +1

    cool and thanks~~ looks better and better~

  • @coverfaker8341
    @coverfaker8341 4 дні тому +1

    Thanks!

  • @OneRomanianGuy
    @OneRomanianGuy 4 місяці тому +1

    would this tutorial work with 2d as well but i just have to change some things to fit 2d?

    • @SunnyValleyStudio
      @SunnyValleyStudio  4 місяці тому

      Grid component works in 2D (it is used for Tilemaps). You could use the same system but your input would probably be just mouse position (no need to raycast anymore)

  • @ОлександрБоровський-н1г

    Great video)

  • @watercat1248
    @watercat1248 Рік тому +1

    This remindmy Sims
    11:45 especially this part

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      Awesome! I hoped it would 🙂 (otherwise I don't think people would watch the tutorial that much 😅)

    • @watercat1248
      @watercat1248 Рік тому

      @@SunnyValleyStudio enway I'm sure I bulding editor like I will be able to be useful for other type off game's well.
      It will be easy to make Sothis like this as map editor for game.
      Or a one off the tools for sandbox game.

  • @gamedevbaiyi936
    @gamedevbaiyi936 Рік тому +1

    Love it.✌

  • @naletovps
    @naletovps 23 дні тому +1

    thanks

  • @pinkdolphin8017
    @pinkdolphin8017 2 місяці тому

    Am I required to purchase the course to get the prefabs shown in this course? Should I find alternative assets or is there somewhere I can download them?

    • @SunnyValleyStudio
      @SunnyValleyStudio  2 місяці тому

      Hey! I always reference the assets used in the description "Assets used: kenney.nl/" . Just search for Furniture Kit there. I will edit the link to point to it directly 👍
      If you like the project and want to support me feel free to grab the paid version 🙂

  • @SalarianStudios
    @SalarianStudios 2 місяці тому +1

    thanks man

  • @Xupra
    @Xupra Місяць тому +1

    thanks!

  • @IliasTompoulidis-p4t
    @IliasTompoulidis-p4t Рік тому +1

    Thanks!

  • @SunghoJang-q6j
    @SunghoJang-q6j 10 місяців тому +2

    I like cheese burger and your lesson tastes very cheese burger.

    • @SunnyValleyStudio
      @SunnyValleyStudio  10 місяців тому +1

      That is the most creative comment that I had on the channel 😄

  • @kilauroombrand5721
    @kilauroombrand5721 Рік тому +1

    thanks

  • @vasilijemilenkovic1069
    @vasilijemilenkovic1069 10 місяців тому +1

    Great vidio

  • @CarlosOrtiz-of5se
    @CarlosOrtiz-of5se 5 місяців тому +1

    Gracias!

  • @81gamer81
    @81gamer81 Рік тому +1

    good stuff comment

  • @Robin-xk1pp
    @Robin-xk1pp 11 місяців тому +1

    How do i change the width of that white part of the Coursor Indicator.

    • @SunnyValleyStudio
      @SunnyValleyStudio  11 місяців тому

      As far as I recall we have used a simple quad with a texture to create preview system. You can modify the texture or create the outline using a shader to be able to smoothly modify how it looks.

  • @coding_game
    @coding_game Рік тому +2

    sir cell indecator not working And download the assets from said?

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      Hey!
      You can check the code here (as I suspect it might be a matter of some missing line of code) github.com/SunnyValleyStudio/Grid-Placement-System-Unity-2022/commit/10d004fefbbac0dcbea0022a53b4ce3ba9c6da89
      Also make sure to set the LayerMask of the cell indicator to something other than default as in the code we want to be detecting the ground. I mention it at 5:25
      I hope it helps!

  • @gheazu6954
    @gheazu6954 10 місяців тому +1

    ty

  • @bollyfun5963
    @bollyfun5963 11 місяців тому +1

    thnks

  • @Rexu3030
    @Rexu3030 Рік тому +1

    I creating project in 3d URP but i haven't this folders and scenes as you.

    • @Rexu3030
      @Rexu3030 Рік тому

      Pls help!

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      It is best to download the full project (ZIP filed), unpack it to a separate folder and use unity Hub "open" on it to add open the same project as I have.
      The scene should be in the "Scenes" folder. Sorry for not explaining it better!

    • @Rexu3030
      @Rexu3030 Рік тому

      @@SunnyValleyStudio thanks

  • @DaffaAP
    @DaffaAP 3 місяці тому +1

    this same for 3d game??

    • @SunnyValleyStudio
      @SunnyValleyStudio  3 місяці тому

      It depends. If you mean 3D like Minecraft you could have a grid that stores x,y,z and when walking shoot calculate the position in front of the player and clamp it to the closest grid position. The core system would work the same as here.

  • @bleedingflower6078
    @bleedingflower6078 8 місяців тому +1

    I have been having this issue where on one side of the plane the grid snaps all the way to the edge and on the other side it only snaps one early. This makes it so on one side it goes outside of the plane. I have been trying to offset things like crazy. The grid, the plane, the gridparent. I even tested with the sphere as grid indicator and still it indicates that it reaches the edge of the plane on one side but not on the other side. I also have tried scaling but just no change works. I am completely lost on why my grid is completely incorrect.

    • @SunnyValleyStudio
      @SunnyValleyStudio  8 місяців тому

      So remember how we convert the world position to grid position? Check using Debug.log what is the world position and what the grid position is. It might be that the grid has an offset and when you reach one of the edges the position is Ceiled (rounded up) ?
      Also remember that we have the grid plane and the ground plane (for simplicity of the setup). The problem might be that one is smaller than the other and when detecting positions on the edge there is actually no collider so the raycast is NULL and the returned position is from the previous row / column. This actually happened to me so maybe that is also an issue in your case?

    • @bleedingflower6078
      @bleedingflower6078 8 місяців тому

      @@SunnyValleyStudio thank you but I already figured it out. I noticed that it qas working correctly however by default it took the bottem left corner of the grid right on the crossing point. So all I had to do was add an offset in code of 0.5f X and 0.5f Z that put it in the center of the square and fixed it. Before that I was trying to do the offset in unity but ofcoarse that gets reset by the code. But thank you for your response I deeply appreciate the efford you put un to help everyone.

  • @dynogamergurl
    @dynogamergurl 8 місяців тому +1

    does this system work with controllers too?

    • @SunnyValleyStudio
      @SunnyValleyStudio  8 місяців тому

      If you are using the new input system you could use the controller as well 👍

  • @amenalaya1417
    @amenalaya1417 Рік тому

    Thanks nice one

  • @Reykoil
    @Reykoil Рік тому +1

    THX!

  • @aleqkzander
    @aleqkzander 8 місяців тому +1

    Thanks :)

  • @walterpalladino1965
    @walterpalladino1965 Рік тому +1

    Thanks!!!

  • @lukgoolaerts3085
    @lukgoolaerts3085 11 місяців тому +1

    Somehow when i follow this tutorial, the sphere (mousepointer) starts where the mouse is, but then flies straight to the camera, and i can't figure out why. Strange

    • @SunnyValleyStudio
      @SunnyValleyStudio  11 місяців тому

      Have you set the Spheres layer to something other than "default" ? I might have gone over this too fast. Basically if sphere has the same layer as the detection layer the sphere will be gradually moving towards the detected point - which is on the surface of the sphere. This will cause it to fly towards the camera.
      Sorry for not explaining it better in the video!

    • @lukgoolaerts3085
      @lukgoolaerts3085 11 місяців тому

      @@SunnyValleyStudio Yes, problem with the layers. instead in changing the layer i added it so, I had the problem you describe above. Thanks for answering

  • @PiFsc2
    @PiFsc2 Рік тому +1

    Is there a tutorial to do this in a 2D based game?

  • @gudfurt8464
    @gudfurt8464 8 місяців тому +1

    I'd like to do something similar in 2d but I'm having some trouble with the input manager. The z index of the circle I'm using as a mouse indicator is at -6.58 even though my near clipping on the camera is set to 0 (started with 0.001) and it's not following the mouse position either (based on inspector values). Any ideas why and what I could do to fix it?

    • @SunnyValleyStudio
      @SunnyValleyStudio  8 місяців тому

      In 2D you actually don't need the Camera Raycast. You would use "Camera.main.ScreenToWorldPoint(Input.mousePosition);"
      Next you would use that to move your Image (since in 2d we don't use spheres 🙂 unless you know what you are doing) and set it as spheres x and y position. Hope it makes sense!
      If you are using the new input system you just need to get the mosuPosition from that 🙂

    • @gudfurt8464
      @gudfurt8464 8 місяців тому

      Thanks for the response! I tried it without the raycast and it worked out perfectly

  • @redinternet9893
    @redinternet9893 Рік тому +1

    Does this apply to uneven ground?

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      Well usually the grid is flat (even if the space includes a mountain it should not take more space than another cell in your grid) - so unless you want an irregular grid the only problem is placing the objects or drawing the grid in accordance with the vertices of the mesh. I am not really sure how our shader would work - I assume that it would handle it. In that case all you would need is to adjust the placement position so that the object aligns with the ground.
      I hope it helps somehow. I haven't tested this system with an uneven ground (like in civilization series)
      *for an irregular grid you would need a custom grid script

  • @bsdrago
    @bsdrago Рік тому +1

    Great!