♟️ Create an Online Chess Game - Placement Grid - 1/5 [Unity tutorial 2021][C#] - creating3dgames.com

♟️ Create an Online Chess Game – Placement Grid – 1/5 [Unity tutorial 2021][C#]

Views: 9414
Like: 254
We create a 3D chess game in unity that includes all the special moves, and that runs a server client architecture. This is a very nice project to learn coding in Unity, and some good c# practice. I would also recommend this series for anyone trying to get into multiplayer with the solutions Unity offers.
Do note that we will be going for the Com.Unity.Transport package for networked code, and not Mirror, or MLAPI.

In this first episode, we lay down a placement grid and ray cast on top of them, highlighting each and every one of the tiles we mouse over. This is going to come in handy when we start selecting the chess pieces.

Link to the Chess Assets, by my friend Z3nder (affiliate) :

Update function :
private void Update()
if (!currentCamera || !boardActive)
currentCamera = Camera.main;

RaycastHit info;
Ray ray = currentCamera.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out info, 100, LayerMask.GetMask(“Tile”, “Hover”)))
// Get the indexes of the tile i’ve hit
Vector2Int hitPosition = LookupTileIndex(info.transform.gameObject);

// If we’re hovering a tile after not hovering any tiles
if (currentHover == -Vector2Int.one)
currentHover = hitPosition;
tiles[hitPosition.x, hitPosition.y].layer = LayerMask.NameToLayer(“Hover”);

// If we were already hovering a tile, change the previous one
if (currentHover != hitPosition)
tiles[currentHover.x, currentHover.y].layer = LayerMask.NameToLayer(“Tile”);
currentHover = hitPosition;
tiles[hitPosition.x, hitPosition.y].layer = LayerMask.NameToLayer(“Hover”);
if (currentHover != -Vector2Int.one)
tiles[currentHover.x, currentHover.y].layer = LayerMask.NameToLayer(“Tile”);
currentHover = -Vector2Int.one;

– – – – –
0:00 Preview
0:32 Getting URP
2:40 Generating Tiles
16:10 Highlighting Tiles
30:27 Code to adjust 3D Assets
– – – – –

►♟️ Learn how to make a Online Multiplayer Chess Game (on Youtube!)

► ⚔️ FREE Top Down RPG Course (on Youtube!):

► Develop a FULL Mobile Game with the help of my Udemy Course :

► Want the files? You can find everything on the website!
► Need help? Join our discord community!

Discord 👊
Website 📡
Email me! 📧 info.epitome.games@gmail.com

Personal channel 🇨🇦

Social Media 🤳

#gameDev #unityEngine #unityTutorial #n3k #epitome


  1. I've added the Chessboard::Update code in the description in case you're having flicker issues. Cheers

  2. Releases will be every Tuesday & Thursday, until our game is complete!

  3. Great my man. You are doing very good. You deserve more subscribers.

  4. I've been looking for a chess engine!

  5. just Yesterday I decided to try and make a chess game but online and here today I see someone posted a video about it

  6. Hi!, I need to ask you something, can you show us how to use play asset delivery? Please

  7. Cool tip for lazy people (7:58)
    instead of writing boilerplate
    string.Format("X:{0}. Y:{1}", x, y)
    you can just write
    $"X:{x}, Y:{y}"
    Much easier to see whats goes where (especially on bigger strings) and avoids having to remember silly string format thing

  8. The tutorial was significantly better than others I have watched on this subject.. until you got to the Hover section. You fixed something with the layers but only showed in the video that you changed the camera to Camera.main. I've missed something though because it still does not work like it did in your video. Either way… Up until that point I really enjoyed your descriptions and explanations as you went through everything else.

  9. people, get him more subscribers, please

  10. Whenever I mouseover my tiles in game, the highlight material flickers. How can I fix this?

  11. with the else statement, it constantly switches the layers back and forth. That's an issue as that creates an annoying blinking efffect.

  12. I have this bug where the tile blinks constantly because of the else statement, how can I fix this?

  13. Anyone else having an issue with importing the board games pack from the asset store? It imports everyone but all of the textures are pink and won't render the graphic 🙁

  14. Can I follow along if I'm trying to do a 2D chess game?

  15. I just found this channel and I am binge watching your videos.

  16. (29:00)

    No Renderer Features added.
    Why might this be, how might I fix this?

  17. I am having issues with the changing of the tiles, for some reason the if (currentHover != hitPosition) statement only works in the first 3-4 frames and then stops. Not sure why this is happening, any help would be greatly appreciated.

  18. I appreciate that you clarify things how/why you do it. This way I understand coding in Unity a lot better.

  19. can i follow this guide also with 2d assets or is it a problem?

  20. Great tut, a few unexplained frame jumps, like @ 16:49 – it isnt explained a currentCamera was declared. Im like 3 months into learning this skill, so I LOVVVVE your educated teachings. So i wanna say thanks for putting this out here for people to learn. #WentToCollegeOnYouTube

  21. What's the root cause of the flickering issue? I copy+pasted the udpate function above, and I don't see any squares at all. I noticed you added boardIsActive boolean. From where are you setting or calling this bool?

  22. Update function in the description has a bracket problem. atm the else statement is for "(currentHover != hitPosition)" and not "(Physics.Raycast(ray, out info, 100, LayerMask.GetMask("Tile", "Hover")))"

  23. Great explanation man! But grid position won't match if boardCenter has y other than 0. The problem is with yOffset I think.

  24. Hey Epitome, so far, this is a very clear tutorial. I followed all the steps about the universal render pipeline (and bought the assets you recommended). Initially they turned up pink, but I changed the render to "Universal Render Pipeline/Lit" (it seems that it is what you have in your tutorial by default but it's not very clear why… for me it was not by default, maybe you could clarify this point a little), and now the board turns to be all white / greyish… I definitely don't see the chess board colors (light and dark brown).
    Do you have any idea / explanation of what is going on ? I tried with unity 2019 and 2020 and got the same issues. I'm sure the issue is not in the code, it must be related to the rendering pipeline… but I can't figure it out 🙁

  25. Hey Can You provide github repo for this project? please!!

  26. Please tell how to find out the board center

  27. why for loop generate list of tiles all naming x:(0),y:(1) 8:44 for me

  28. big fan

Leave a Reply

Your email address will not be published. Required fields are marked *