Grid System in Unity (Heatmap, Pathfinding, Building Area)

preview_player
Показать описание
Let's make a Grid System that we can use to split our World into various Grid Cells.
Then we can use that to make a Heatmap or a Pathfinding Map with avoid/desire areas or a Building Grid System.

Complete Grid System in Unity Playlist

Powerful Generics Added! Grid System in Unity!

Learn Unity in 17 MINUTES!

Learn C# BASICS in 10 MINUTES!

Battle Royale Tycoon on Steam

Make Awesome Effects with Meshes in Unity | How to make a Mesh

If you have any questions post them in the comments and I'll do my best to answer them.

See you next time!

#unitytutorial #unity3d #unity2d

--------------------------------------------------------------------

Hello and welcome, I am your Code Monkey and here you will learn everything about Game Development in Unity 2D using C#.

I've been developing games for several years with 7 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.

--------------------------------------------------------------------

Рекомендации по теме
Комментарии
Автор

Here's a great class to serve as a base for you to make some really awesome systems like a Heatmap, Pathfinding, Building, etc.

CodeMonkeyUnity
Автор

Thank you so much for your tutorials, Monkey. Ever since Brackeys went dark, I've sort of been lacking direction and motivation for game development, but you've given those things back to me, my dude. What a gamer. Much love.

gavn
Автор

16:55 if only the value in the middle of the screen changes, change your camera from "perspective" to "orthographic" in the inspector of the camera. Thank you for the tutorial, really helpful!

haydenk
Автор

I find the sped up keyboard sound very satisfying to listen to

WesleyOverdijk
Автор

Holy you're a life saver, I couldn't find a tile systems after the changes to gameobject codes

kaheichan
Автор

Big help on a "city builder" style game I'm working on, or not to mention anything I do involving grids from now on. Thanks a million!

zombievirals
Автор

Null Reference Exception issue:

If you're having issues with Null Reference Exception when changing the value of the grid elements, try checking your test script to see if your start function is "Grid grid = new Grid(4, 2, 10f);" if it is, delete that first Grid and leave it as "grid = new Grid(4, 2, 10f);" this fixed it for me as I hadn't noticed him delete it.

lukehughes
Автор

Hey man, I just wanted to thank you for this playlist, it definitely really helped me on my project. When I first time watches this, I did struggle in understanding several part because I'm new to c#, so I decided to watch some tutorial on c# first, then when I came back, I understand most of what are you saying, thank you for this awesome tutorial!

reganharvan
Автор

If anyone is having problems implementing the EventHandler OnGridValueChanged from the end of the this video, check out 3:37 of the cool heatmap video in the series, lines 55 - 57 of the code. For this video, I implemented 22:19 lines 9 - 10, and 22:23 line 73, but I kept getting a null value for OnGridValueChanged. After implementing 3:37, lines 55 - 57 from the cool heatmap video, OnGridValueChanged got updated to a non-null value.

zishiwu
Автор

Great tutorial, mind freshing. I learned so much just from the first episode and the way that you code step by step following a comprehensive beginner's mindset is so so so helpful! I also install the Utilities and I'm expecting to use them in my other practicing projects! Thank you!

JessePan
Автор

Quick note for what you mentioned about returning a struct around 14:30: In C#, you may also return an anonymous tuple from methods. public (int, int) GetXY(Vector3 worldPosition) or public (int x, int y) GetXY(Vector3 worldPosition) would return such a Tuple. In the first case, you can access individual values with value.Item1 and value.Item2, in the second case with value.x and value.y.

maximejacob
Автор

Awesome tutorial! I was just about to comment how it can be improved by making the Grid generic, but jokes on me, you already have that covered in another video.

There are tons of good tutorials out there, but many fall apart once you try to go beyond the basic implementation of the tutorial. Your tutorials really show that you got a deep understanding of programming and your code is easily expandable.

Keep up the good work, you are a blessing for the Unity community! Much love.

Zure
Автор

This is like the beginning of a new topic for me - Grid system. THanks for the tutorial!

sadiqabbaszade
Автор

I purchased your game bundle, and I'm sure my son will LOVE THEM!
Who knows, even old me might like them! I usually play casual games. :)

pamhs
Автор

love your vids! I appreciate all you do! personally I find the Sped up footage of you writing code to be a little frustrating as I like to follow along as you write code and I have to pause to keep up. just stating my opinion. even so, please know I do appreciate all of this ! thank you, thank you. can't wait to learn more!

tsuaeghakihas
Автор

Hey Code Monkey, I don't know if you will see this but I was wondering if you had any comments on the differences between unity's grid component versus this grid class you created? Can you implement the two to work together? Or do the work best if they are independent? At the time of making this video did you have the grid component available to you?

Does all of this functionality already exist on the grid component?

brandonmitchell-kiss
Автор

I managed to turn this into a grid that works with the Isometric Z as Y tilemap that tracks elevation levels. And could expand it to keep track of tiles that extend way beyond the elevation level. Thank
you for a tutorial on this awesome "tool".

lolownq
Автор

Enjoying your tutorials, thanks, very helpful. I especially enjoy that you include some testing here and there to see things working out; that helps with understanding and makes the tutorial more enjoyable. Well done and thanks!

StevePaceS
Автор

If you are having issues where you keep getting the camera transform position from GetMouseWorldPosition it may be because your camera is set to perspective. I was having this issue and the way I fixed it was by setting the camera to orthographic although you could also use a raycast to a plane on the grid's z axis if you want to keep the camera as perspective.

JosephWright-zqhl
Автор

For the new input system :P

using UnityEngine;
using UnityEngine.InputSystem;

public class GridTester : MonoBehaviour
{

private NovGrid grid;
private void Start()
{
grid = new NovGrid(4, 2, 10f);
}

private void Update()
{
if
{
grid.SetValue(GetMouseWorldPosition(), 42);
}
}


public static Vector3 GetMouseWorldPosition()
{
Vector3 vec = GetMouseWorldPositionWithZ(Mouse.current.position.ReadValue(), Camera.main);
vec.z = 0f;
return vec;
}

public static Vector3 screenPosition, Camera worldCamera)
{
Vector3 worldPosition =
return worldPosition;
}
}

Novixel