I really like your tutorials! I also wish they were more patient with the viewer! Like @6:56 there's barely a moment between the finished line of code and moving onto the next one. Links to previous videos when that information is presented would be helpful too. I got so confused in the first part when the white tile suddenly appeared. I took your advice and looked at the Unity API and found the answer. It'd be super helpful in the future to have links or annotations for anything related to the video but not covered in it!
Hi, at 12:15 and in other points throughout the video, I really don't understand what is going on with these "v:Vector3Int"s and "x:" as I use Visual Studio Code and it doesn't seem to have this. If someone could explain as it's giving me errors when I add these and also when I remove them. Can someone help? It's a bit frustrating as I have no idea what the visual studio code equivalent to "v:" is. Edit, these are called IDEs and in "v:Vector3Int", u just ignore the Vector3Int and type "var v in ..."
Currently making a RTS game where there is a builder unit that can build things. I'm also watching a video about building nav meshes in realtime so that the units can easily move around the buildings. Thank you a lot for the video!
hey if you havent figured this out yet you shouldn't use nav meshes for an rts try searching A* pathfinding and flowfeild pathfinding they are much faster for performance and with flowfeild you could have selected troops all follow a point only needing caculations for naviagation once instead of 20 -30 times that nav meshes would do
@Spectrum 13 there is a code to find all navpaths for each agent. And once calculation is finished, run all paths ant once so all agents move at the same time
Hello! I tried following the tutorial but however, I'm having some issues with the object drag. It doesn't function the same when I tried to drag my cube around. Not sure what is the problem.
Hello! You can ask about this on my discord server and provide more details. Maybe someone might help you, there is an amazing gamedev community there. Link - discord.gg/dCJBpe2meg Object drag is not the main part of the system so if something doesn't work you can write your own object drag that works for your project
Thank you for this amazing tutorial! This helped me a lot. I found a bug(?) at 13:02, you correct `area.size = new Vector3Int(area.size.x + 1, area.size.y + 1, area.size.z);` but it should actually be `area.size = new Vector3Int(placeableObject.Size.x + 1, placeableObject.Size.y + 1, placeableObject.Size.z);`, otherwise size will always be (1, 1, 0) as area is just initialized two lines above? Swapping to placeableObject.Size worked fine for me on preventing from placing an object on taken area.
Hi, glad you liked the tutorial! As for your bug report, there should be a line just above the one you mentioned where I assign the Placeable Object's area to the area size. And then I add 1 to each coordinate. But you're right, it would have been better to do this right away as you suggested. Nice catch 😉
@@TamaraMakesGames Thanks for your reply! Ahhh I see! I totally misunderstood what you said! not swapping but re-assgining "area.size" to area! My bad😅
Im confused. We code A and B to place prefabs, but what is Spacebar doing? I can place items, but they stack ontop of each other and disregard anything. Also no white tiles are being created when I place anything.
A and B are for getting the objects. The spacebar is for actually placing them. You'd want to change these inputs to something like buttons on the screen in your game. As for the placing issue, look through the CheckPlacement method. Also, make sure that you're actually triggering the placement (pressing the spacebar). If you haven't done that the buildings might have just stacked on each other each time you pressed A or B.
Hi! Thanks! So the reason I do this is because when we're calling the method to paint a block of tiles it compresses the boundaries of a tilemaps to the minimum. The painting will simply not work outside that box. So if you don't have any tiles on the tilemaps it won't paint anything at all
@@TamaraMakesGames Glad to hear! One recommendation I have is that when you reference your older videos that contain necessary skills, is it possible to place a clickable link to that video on yours? No worries if not, its very easy to just click and see what one you meant :)
You make a valid point. I usually include links in the tips that are shown at the top right. But I guess I might have missed them in this one. Thanks for telling me
Hey, great tutorial! I just had one question tho, is it also possible to make it so that let's say I am using this to decorate the inside of an house. To place things on tables and such? Like an object that has an elevation. (take PewDiePie sim for example, there you can place a table and then place other objects on that table but also on the ground, it just elevates on top of the object. Although in my case the tables are already there, I just need to place objects on it or on the floor)
5:08 for me on line 18 it is giving the error of Error:The type or namespace name 'PlaceableObject' could not be found (are you missing a using directive or an assembly reference?) with Code:CS0246 any ideas/suggestions?
@@TamaraMakesGames ok so the problem was it put: public class NewBehaviourScript : MonoBehaviour not: public class public class PlaceableObject: MonoBehaviour in PlaceableObject.cs.
Hi Tamara, very good tutorial. But I have a problem when I try to move the object, where when moved with the mouse, the object returns to where it was spawned. Does anyone have the same problem as me?
Hi! Thanks! Check the grid snapping, maybe there is an error. Maybe the delta distance is calculated wrong so it snaps to the same position. And check if the coordinate conversions are correct (screen to world)
Great video! I'm wondering if it would be possible to have more than one collider? for example having an L-shaped building and needing two colliders for that, how would that work?
Hii, nice video, thanks for the tutorial, I have an issue and I've seen a few comments and threats on the Discord server with the same issue, all works correctly BUT the function to know if the cell is empty or not (CanBePlaced()) seems to return always true, because of that, I can Place buildings over buildings infinitely, some help with that?¿
Hello, I have a plane and its type is a cargo plane. I want to make a grid system for this with 3 different short side and long side dimensions. Do you think this video will help with this? Can it be converted to the shape I want?
Hi, I think yes, this video can help you. The system works with buildings that are not just squares. You just have to stretch the box collider and be careful to not mix up the coordinates when calculating the building size. and if you were talking about the shape of the building field itself, that can be achieved too. You would just need to define the borders of the available area by painting white tiles (the taken tiles).
Hi Tamara, I really love your video. But the time is long and something have been changed. I followed your tutorial but I stucked from Part 2: Building Placement. My grid is not fill right with prefab and I can build a lot of prefab in 1 cell. Can you review your code for any update to fix those bugs?
Hey Tamara, I thought this was a great tutorial, but I'm just having one problem. I'm getting the error "Object reference not set to an instance of an object - PlaceableObject.GetStartPosition" I'm not sure how to fix this, but it is probably because I didn't really know what you filled into the CalculateSizeInCells method as you skipped over it a bit, but if you could try to help, that would be great! Lots of love from Ireland :)
Hey, there! I would like to help you but I need more information on the issue you're having. Just share the line of code that's giving you the error - I assume it is somewhere in the GetStartPosition method. Also, I would appreciate if you do it in my Discord server (channel help) - discord.gg/dCJBpe2meg And cheers from Ukraine 🇺🇦
Hello maam. Do you have a simple sitting on chair tutorial?Like there will be an arrow on top chair and when you click it you will sit on chair. Thank you sir.
An amazing video, and with not too much effort as well! However, I noticed these one or two "main" issues while I was trying to implement this myself. I've checked and everything seems to be the same as the video, but it just doesn't seem to work. When I try to *place an object that is larger than 1 square unit size* (e.g. an object that is 3x3 units), the white tiles appear, but instead of filling the entire 3x3 area, *only one tile appears at the corner* , while the other 8 tiles that it should occupy remains empty. Also, another problem (Maybe related to the top problem but unsure), *after placing the object, I can place another in the exact same area* , and it seems like the CanBePlaced method doesn't really work as intended, or just keeps returning true and never false. I would appreciate any help on this. Thanks!
Hello! Thank you, I'm glad you liked the video. As for the issues, the first one to do is to check what positions are in your area and if they are correct. Also, check if the size detection works well. One of my guesses is that your tilemap can have small bounds. Make sure that you placed a border of tiles around the area. Considering the second issue, it must be something wrong with positions so check those. I recommend doing some debugging and really getting inside of your code. If you still continue having issues, come up to my Discord server, maybe we'll solve these issues all together. Link to join - discord.gg/dCJBpe2meg
What if instead of selecting a prefab with a keyboard key, i want to select the prefab from a menu with my cursor? how would i implement that into my code?
hello can you help i finished the code but it give me error Assets\scripts\BuildingSystem.cs(18,13): error CS0246: The type or namespace name 'PlaceableObject' could not be found (are you missing a using directive or an assembly reference?) do you know anyway on how to fix this?
You need to do some debugging and provide me with more information to solve this issue. Perhaps use my discord server for this - discord.gg/dCJBpe2meg And thanks, I'm glad you liked the tutorial!
Hi Tamara, thanks for all these tutorials, they are helping me in my project. I was working on the Building System script, but then I type private PlaceableObject, it is not recognize, do you know why could be the reason?
Hi there! I'm glad you liked my tutorials. As for your issue, make sure you have created the class placeable object and you don't have typos in its name.
Hi i love your Tutorials. But right now im having a Problem with your example. To get the Tilesinformation you iterate over area.allPositionsWithin in class GetTilesBlock(). i have copied it exactly and it doesn't go into the foreach loop. i've tested the area param, but it contains data. private static TileBase[] GetTilesBlock(BoundsInt area, Tilemap tilemap) { Debug.Log("area contain data: " + area.allPositionsWithin.GetEnumerator().Current); TileBase[] array = new TileBase[area.size.x * area.size.y * area.size.z]; int counter = 0; foreach (var v in area.allPositionsWithin) { Vector3Int pos = new Vector3Int(v.x, v.y, 0); array[counter] = tilemap.GetTile(pos); counter++; Debug.Log("data of variable: " + v); } return array; } Are u able to help me out :D Thanks so much!!
Hello! That is definitely an unexpected behavior. Your code is perfectly fine so maybe the problem is elsewhere. Try to do some debugging and check the size of your area.
I think you have to switch from `area.size = new Vector3Int(area.size.x + 1, area.size.y + 1, area.size.z);` to `area.size = new Vector3Int(placeableObject.Size.x + 1, placeableObject.Size.y + 1, placeableObject.Size.z);` in CanBePlaced funciton. I am not sure what issue you have but in my case, I could place an object on area where is already taken by others. If you have the same issue, switching area.size to placeableObject.Size would solve it.
Hello, I have some problems with the system, when I drag them on the scene the collision with others building is not detected so I can place 2 buildings in the same position. How can I fix that?
Hello! This system is not based on collisions it checks the area under buildings. Check if your building sizes are correct and also the method that checks for the area availability
Hello, I've been pulling my hair our and hoping you can help. I followed the Tutorial and it worked great! except when I try to implement a system to delete an object that was placed, i can get the object to delete but I cant for the life of me get the tile to change from the white tile. please help, anyone
Hi! To remove a tile from the tilemap you would have to set the tile at that position to null. A common issue is the position that you're passing into the SetTile function. Check if the coordinates are correct. If you have successfully set tiles when placing a building then you can modify that code to set the tile to null.
It places the white tile and building just fine, i can even get it to remove the object, but the tile stays white no matter what i do. @@TamaraMakesGames
It should be Vertices with the capital V. I'm pretty sure that's what's causing the error. Another person had this issue and posted it on my Discord discord.gg/dCJBpe2meg
Hi Tamara, Amazing Video, But in my case everything works fine but the *objet isnt filling the tilemap exactly* (Actually its filling upper area from TilemapGrid) so CAnbePlaced always return as true(cuz tiles painting wrong),, when i paint manuallly its return false; Help Me Please, Love From Sri Lanka
Hey there! Thank you! And as for your question, try understanding why the position is not correct. One of the reasons is that you moved the tilemap object or the camera and now the positions are shifted. I recommend debugging and seeing the positions or, a more visual method, try making a method that fills up one tile on your mouse click. It'll help you better understand. You can also place a tile at the zero position and see where it is. Hope that helps! Greetings from Ukraine 👋🇺🇦
@@TamaraMakesGames Thanks For Your Fast Reply , I've Modified the Code My Own Way and now its functioning properly, It's Sad to hear Tht You are From Ukraine, What is the situation on ur area 😪🤐 Praying for Ukraine 🙏
Glad to hear that you fixed things! And thank you for the support. You can join my Discord to find out more about my current situation - discord.gg/dCJBpe2meg
Hey Tamara, it looks like it doesn't work when there's only 1 tile sized object, it's placing it there and event filling it, but detecting the tile using the "CanBePlaced" doesn't work for me, does it work for you?
I mentioned in the video that the size has to be increased by 1 on both axes because when it is calculated it is smaller. Try debugging and see if the size is actually 1 and not 0
Hello :) How would I go about allowing the building to follow the mouse until I place it down? Im having trouble with using Left Mouse to click on UI to Initilize the Build as well. Thanks!!
Hey there! Following the mouse would be easy, just get the mouse position in the update method, perform some raycasting like I did in this tutorial to get the world position, and assign the new position to the transform of an object you want to move. As for the left mouse clicks, I can't really help with that, but I suggest you try asking in my discord server, maybe somebody there knows. Link to join - discord.com/invite/dCJBpe2meg
Hi there! You have to modify the initialize with building method in the grid building script. Instead of vector3 zero pass the mouse position in world space
@@TamaraMakesGames I tried something and changed so that the object spawns on the the mousePosition but not on my terrain, it spawns on the canvas My Code: public Vector3 SnapCoordinateToGrid(Vector3 position) { Vector3Int cellPos = gridLayout.WorldToCell(position); position = grid.GetCellCenterWorld(cellPos); return position; } #endregion #region Building Placement public void InitializeWithObject(GameObject prefab) { Vector3 mousePos = Input.mousePosition; GameObject obj = Instantiate(prefab, mousePos, Quaternion.identity); objectToPlace = obj.GetComponent(); obj.AddComponent(); }
Hello, thank you for the video it really helped me but I have a question. When we destroy the prefab using echap, the white tiles don't disapear. How can we erase them ?
Hi there! I'm glad you found my video helpful. I think you're not calling the erase method after destroying a building. In the building system script should be a method for clearing tiles on some territory.
Depends on how your axes are rotated and which wall it is. If your y axis points upward your coordinates can be on x and y on one wall, and y and z on the other wall.
I tried something and changed so that the object spawns on the the mousePosition but not on my terrain, it spawns on the canvas. How can i fix it? My Code: public Vector3 SnapCoordinateToGrid(Vector3 position) { Vector3Int cellPos = gridLayout.WorldToCell(position); position = grid.GetCellCenterWorld(cellPos); return position; } #endregion #region Building Placement public void InitializeWithObject(GameObject prefab) { Vector3 mousePos = Input.mousePosition; GameObject obj = Instantiate(prefab, mousePos, Quaternion.identity); objectToPlace = obj.GetComponent(); obj.AddComponent(); }
You didn't convert your mouse position to world point. And it is better done with ray casting in 3d. I featured this function in the grid building script
That's actually expected behavior. You have to click on your prefab (triggering OnMouseDown) and drag it (Triggering OnMouseDrag) to drag it to the desired position.
İ wanted to remake this script, but İ get an error by "[SerialzeField] private Tilemap MainTilemap", its saying that Tilemap can't be found, how can İ fix it
Hi there! Thank you! As of such maps, this particular system can't do that because it is based on the Unity tilemaps which don't have such option. But it is a very interesting topic so maybe I'll look into it 🙂
do not follow this tutorial. There are newer method which support more. Watching this will not waste your time though, you will learn how to configure unity even if it do not help you for this task.
Maybe next time don't skip some isntructions like how to create a tile from a sprite, it's just appearing like that for you but for beginners it was a nightmare to figure what it was
Hi Tamara, How are you, I suggest you make a series of RTS games, knowing that there is no content on RUclips to prepare a course for it. Even if it is paid, I will buy it to support you. I hope you will fulfill my request and be 3D
Hey there! Thank you for your suggestion I will definitely take it into consideration. If I were to make such tutorial series, what features are you interested in?
Great video and code Tamara, I am a Patrone sponsor! One thing, I do not know if I made anything wrong but when I place a house/object I color the tiles but when I then move it those colored tiles remain. Another thing, the second time I place an object it cannot be moved anymore (after first placement I can move it one more time), last thing, when I move an object it does not become the current object so when I rotate it then another object rotates instead. What can I do?
You shouldn't name both private variables and public properties with CamelCase. Private should start with _or something else otherwise it's way too hard to debug. You'll thank yourself later
If you're talking about a freelance offer, I don't take those at the moment. If you just want to get help implementing t he system in your project you can come up to my Discord server - discord.gg/dCJBpe2meg
@@TamaraMakesGamesWe can met on wat app because discord have problem don't work and im not undestand if i need pay you if you doing as job programming cs?
The hardest tutorial videos I've ever watched in my life are yours, the code structure is already bad and you explain very incompletely as if you bought the codes from someone else and didn't write them yourself.
In what game would you use this system?
In some clone of Dofus,
have you ever played it ?🤔
@@laudh I haven't, but I looked it up and it seems interesting
In mobile tower defense game inspired with Power Towers TD from warcraft3.
Is it possible to make a real time PvP player based on this kind of tile maps?
@@aoboard In my opinion, this system is independent of any other parts of the game so you can build any game you want with it.
I really like your tutorials! I also wish they were more patient with the viewer! Like @6:56 there's barely a moment between the finished line of code and moving onto the next one. Links to previous videos when that information is presented would be helpful too. I got so confused in the first part when the white tile suddenly appeared. I took your advice and looked at the Unity API and found the answer. It'd be super helpful in the future to have links or annotations for anything related to the video but not covered in it!
Hi, my system is not working like it shows on 8:16 of the video. Someone know why it could be??
Hi, at 12:15 and in other points throughout the video, I really don't understand what is going on with these "v:Vector3Int"s and "x:" as I use Visual Studio Code and it doesn't seem to have this. If someone could explain as it's giving me errors when I add these and also when I remove them. Can someone help? It's a bit frustrating as I have no idea what the visual studio code equivalent to "v:" is.
Edit, these are called IDEs and in "v:Vector3Int", u just ignore the Vector3Int and type "var v in ..."
Currently making a RTS game where there is a builder unit that can build things. I'm also watching a video about building nav meshes in realtime so that the units can easily move around the buildings. Thank you a lot for the video!
Interesting, good luck with your project! I'm glad that you liked the video :-)
hey if you havent figured this out yet
you shouldn't use nav meshes for an rts try searching A* pathfinding and flowfeild pathfinding
they are much faster for performance
and with flowfeild you could have selected troops all follow a point only needing caculations for naviagation once instead of 20 -30 times that nav meshes would do
@Spectrum 13 there is a code to find all navpaths for each agent. And once calculation is finished, run all paths ant once so all agents move at the same time
Hello! I tried following the tutorial but however, I'm having some issues with the object drag. It doesn't function the same when I tried to drag my cube around. Not sure what is the problem.
Hello! You can ask about this on my discord server and provide more details. Maybe someone might help you, there is an amazing gamedev community there. Link - discord.gg/dCJBpe2meg
Object drag is not the main part of the system so if something doesn't work you can write your own object drag that works for your project
Great video
Your content is getting better and better
Keep up the great work 👌
Thank you so much! I will!
Thank you for this amazing tutorial! This helped me a lot.
I found a bug(?) at 13:02, you correct `area.size = new Vector3Int(area.size.x + 1, area.size.y + 1, area.size.z);` but it should actually be `area.size = new Vector3Int(placeableObject.Size.x + 1, placeableObject.Size.y + 1, placeableObject.Size.z);`, otherwise size will always be (1, 1, 0) as area is just initialized two lines above? Swapping to placeableObject.Size worked fine for me on preventing from placing an object on taken area.
Hi, glad you liked the tutorial!
As for your bug report, there should be a line just above the one you mentioned where I assign the Placeable Object's area to the area size. And then I add 1 to each coordinate. But you're right, it would have been better to do this right away as you suggested. Nice catch 😉
@@TamaraMakesGames Thanks for your reply! Ahhh I see! I totally misunderstood what you said! not swapping but re-assgining "area.size" to area! My bad😅
This comment fixed my problem thank you!
This is sweet! Thanks for this Tamara!
Thank you!
Im confused. We code A and B to place prefabs, but what is Spacebar doing?
I can place items, but they stack ontop of each other and disregard anything. Also no white tiles are being created when I place anything.
A and B are for getting the objects. The spacebar is for actually placing them. You'd want to change these inputs to something like buttons on the screen in your game.
As for the placing issue, look through the CheckPlacement method. Also, make sure that you're actually triggering the placement (pressing the spacebar). If you haven't done that the buildings might have just stacked on each other each time you pressed A or B.
Make sure you added the placeable object script to your prefab
Hi! Great video
Why at about 14:30 you manually paint this "boundary box" saying that it is needed to work correctly? I don't get it :(
Hi! Thanks!
So the reason I do this is because when we're calling the method to paint a block of tiles it compresses the boundaries of a tilemaps to the minimum. The painting will simply not work outside that box. So if you don't have any tiles on the tilemaps it won't paint anything at all
I needed to know how to snap co ords in grid for personal proj , Thanks!!!
Thanks for another awesome video! Hope you're staying safe!
I'm super glad that you liked it! And thanks, I am trying to stay safe
@@TamaraMakesGames Glad to hear! One recommendation I have is that when you reference your older videos that contain necessary skills, is it possible to place a clickable link to that video on yours? No worries if not, its very easy to just click and see what one you meant :)
You make a valid point. I usually include links in the tips that are shown at the top right. But I guess I might have missed them in this one. Thanks for telling me
@@TamaraMakesGames thanks for helping me with this tutorial!!
Hey, great tutorial!
I just had one question tho, is it also possible to make it so that let's say I am using this to decorate the inside of an house. To place things on tables and such? Like an object that has an elevation. (take PewDiePie sim for example, there you can place a table and then place other objects on that table but also on the ground, it just elevates on top of the object. Although in my case the tables are already there, I just need to place objects on it or on the floor)
Great job. Really high quality tutorial
Thank you!
5:08 for me on line 18 it is giving the error of Error:The type or namespace name 'PlaceableObject' could not be found (are you missing a using directive or an assembly reference?) with Code:CS0246
any ideas/suggestions?
Create the script PlaceableObject and make sure it is in the same namespace as your other scripts
@@TamaraMakesGames ok so the problem was it put: public class NewBehaviourScript : MonoBehaviour
not: public class public class PlaceableObject: MonoBehaviour in PlaceableObject.cs.
This grid building was an absolutely amazing base for me! Thank you so much!!
I'm so happy to hear that! Thank you! 😄
Tus videos son de increíble ayuda, greetings from Spain!
Thank you! I am glad that you like the videos! Greetings from Ukraine
Hi Tamara, very good tutorial. But I have a problem when I try to move the object, where when moved with the mouse, the object returns to where it was spawned. Does anyone have the same problem as me?
Hi! Thanks!
Check the grid snapping, maybe there is an error. Maybe the delta distance is calculated wrong so it snaps to the same position. And check if the coordinate conversions are correct (screen to world)
Спасибі за туторіал, саме те що потрібно для моє гри симулятора трубопроводчика)
Будь ласка! Рада що туторіал був вам корисним!
Great video! I'm wondering if it would be possible to have more than one collider? for example having an L-shaped building and needing two colliders for that, how would that work?
Discovered you today, very clear and precise instructions. A great addition to the community of game developers. Respects and love from Pakistan
I am delighted to read this! Thank you for your kind words! Greetings from Ukraine
@@TamaraMakesGames hey, my prayers are with Ukraine and it's innocent citizens. May things get better soon for you my friend.
thank you tamara, nice video !!!
Thank you!
Hii, nice video, thanks for the tutorial, I have an issue and I've seen a few comments and threats on the Discord server with the same issue, all works correctly BUT the function to know if the cell is empty or not (CanBePlaced()) seems to return always true, because of that, I can Place buildings over buildings infinitely, some help with that?¿
Hello, I have a plane and its type is a cargo plane. I want to make a grid system for this with 3 different short side and long side dimensions. Do you think this video will help with this? Can it be converted to the shape I want?
Hi, I think yes, this video can help you. The system works with buildings that are not just squares. You just have to stretch the box collider and be careful to not mix up the coordinates when calculating the building size. and if you were talking about the shape of the building field itself, that can be achieved too. You would just need to define the borders of the available area by painting white tiles (the taken tiles).
Hi Tamara, I really love your video. But the time is long and something have been changed. I followed your tutorial but I stucked from Part 2: Building Placement. My grid is not fill right with prefab and I can build a lot of prefab in 1 cell. Can you review your code for any update to fix those bugs?
Hey Tamara, I thought this was a great tutorial, but I'm just having one problem. I'm getting the error "Object reference not set to an instance of an object - PlaceableObject.GetStartPosition" I'm not sure how to fix this, but it is probably because I didn't really know what you filled into the CalculateSizeInCells method as you skipped over it a bit, but if you could try to help, that would be great! Lots of love from Ireland :)
Hey, there! I would like to help you but I need more information on the issue you're having. Just share the line of code that's giving you the error - I assume it is somewhere in the GetStartPosition method.
Also, I would appreciate if you do it in my Discord server (channel help) - discord.gg/dCJBpe2meg
And cheers from Ukraine 🇺🇦
@@TamaraMakesGames I’ll join the discord now, and thanks for the incredibly quick response :D
I just happened to be answering the comments
Hello maam.
Do you have a simple sitting on chair tutorial?Like there will be an arrow on top chair and when you click it you will sit on chair.
Thank you sir.
An amazing video, and with not too much effort as well! However, I noticed these one or two "main" issues while I was trying to implement this myself. I've checked and everything seems to be the same as the video, but it just doesn't seem to work.
When I try to *place an object that is larger than 1 square unit size* (e.g. an object that is 3x3 units), the white tiles appear, but instead of filling the entire 3x3 area, *only one tile appears at the corner* , while the other 8 tiles that it should occupy remains empty.
Also, another problem (Maybe related to the top problem but unsure), *after placing the object, I can place another in the exact same area* , and it seems like the CanBePlaced method doesn't really work as intended, or just keeps returning true and never false.
I would appreciate any help on this. Thanks!
Hello! Thank you, I'm glad you liked the video. As for the issues, the first one to do is to check what positions are in your area and if they are correct. Also, check if the size detection works well. One of my guesses is that your tilemap can have small bounds. Make sure that you placed a border of tiles around the area.
Considering the second issue, it must be something wrong with positions so check those.
I recommend doing some debugging and really getting inside of your code. If you still continue having issues, come up to my Discord server, maybe we'll solve these issues all together. Link to join - discord.gg/dCJBpe2meg
@@TamaraMakesGames Thank you so much, i was having the same problem. great tutorial.
This is a great channel, informative and top tutorials
Thank you so much for your kind words!
go you dude love what ya doing
What if instead of selecting a prefab with a keyboard key, i want to select the prefab from a menu with my cursor? how would i implement that into my code?
Is it possible to integrate this with the custom tilemap brush?
hello can you help i finished the code but it give me error Assets\scripts\BuildingSystem.cs(18,13): error CS0246: The type or namespace name 'PlaceableObject' could not be found (are you missing a using directive or an assembly reference?)
do you know anyway on how to fix this?
Hi, did you create the script PlaceableObject? Make sure you didn't make any typos in the class declaration
@@TamaraMakesGames yea made the script added it to prefabs and I checked nothing wrong
I have the same issue atm
I have solved the issue by deleting the script PlaceableObject and recreating it. Now the script BuildingSystem is functioning as intended.
Do you think this style of grid control would work with a hex grid?
so if I place the object only one tile appears and if I destroy the object that one tile doesnt go away! please someone help me! greet tutorial btw!
You need to do some debugging and provide me with more information to solve this issue. Perhaps use my discord server for this - discord.gg/dCJBpe2meg
And thanks, I'm glad you liked the tutorial!
I love you Tamara 🥰🤗thanks for amazing tutorial.
Hi Tamara, thanks for all these tutorials, they are helping me in my project. I was working on the Building System script, but then I type private PlaceableObject, it is not recognize, do you know why could be the reason?
Hi there! I'm glad you liked my tutorials. As for your issue, make sure you have created the class placeable object and you don't have typos in its name.
@@TamaraMakesGames Now, it makes sense now, I didnt create the placeableObject script file, now it's working, thank you
you have to create the script at first
Hi i love your Tutorials. But right now im having a Problem with your example. To get the Tilesinformation you iterate over area.allPositionsWithin in class GetTilesBlock(). i have copied it exactly and it doesn't go into the foreach loop. i've tested the area param, but it contains data.
private static TileBase[] GetTilesBlock(BoundsInt area, Tilemap tilemap)
{
Debug.Log("area contain data: " + area.allPositionsWithin.GetEnumerator().Current);
TileBase[] array = new TileBase[area.size.x * area.size.y * area.size.z];
int counter = 0;
foreach (var v in area.allPositionsWithin)
{
Vector3Int pos = new Vector3Int(v.x, v.y, 0);
array[counter] = tilemap.GetTile(pos);
counter++;
Debug.Log("data of variable: " + v);
}
return array;
}
Are u able to help me out :D Thanks so much!!
Hello! That is definitely an unexpected behavior. Your code is perfectly fine so maybe the problem is elsewhere. Try to do some debugging and check the size of your area.
I think you have to switch from `area.size = new Vector3Int(area.size.x + 1, area.size.y + 1, area.size.z);` to `area.size = new Vector3Int(placeableObject.Size.x + 1, placeableObject.Size.y + 1, placeableObject.Size.z);` in CanBePlaced funciton. I am not sure what issue you have but in my case, I could place an object on area where is already taken by others. If you have the same issue, switching area.size to placeableObject.Size would solve it.
Hello, I have some problems with the system, when I drag them on the scene the collision with others building is not detected so I can place 2 buildings in the same position. How can I fix that?
Hello! This system is not based on collisions it checks the area under buildings. Check if your building sizes are correct and also the method that checks for the area availability
Hello, I've been pulling my hair our and hoping you can help. I followed the Tutorial and it worked great! except when I try to implement a system to delete an object that was placed, i can get the object to delete but I cant for the life of me get the tile to change from the white tile. please help, anyone
Hi! To remove a tile from the tilemap you would have to set the tile at that position to null. A common issue is the position that you're passing into the SetTile function. Check if the coordinates are correct. If you have successfully set tiles when placing a building then you can modify that code to set the tile to null.
It places the white tile and building just fine, i can even get it to remove the object, but the tile stays white no matter what i do. @@TamaraMakesGames
Hey @Tamara Make Game. Wonderful tutorial. I had a problem but I found a solution. Your tutorial gave me a headstart
It should be Vertices with the capital V. I'm pretty sure that's what's causing the error. Another person had this issue and posted it on my Discord discord.gg/dCJBpe2meg
@@TamaraMakesGames the problem was the declaration. I fixed it by using [] instead of () that I used before. Thank you so much for your response
Hi Tamara, Amazing Video, But in my case everything works fine but the *objet isnt filling the tilemap exactly* (Actually its filling upper area from TilemapGrid) so CAnbePlaced always return as true(cuz tiles painting wrong),, when i paint manuallly its return false;
Help Me Please, Love From Sri Lanka
Hey there! Thank you! And as for your question, try understanding why the position is not correct. One of the reasons is that you moved the tilemap object or the camera and now the positions are shifted. I recommend debugging and seeing the positions or, a more visual method, try making a method that fills up one tile on your mouse click. It'll help you better understand. You can also place a tile at the zero position and see where it is. Hope that helps! Greetings from Ukraine 👋🇺🇦
@@TamaraMakesGames Thanks For Your Fast Reply , I've Modified the Code My Own Way and now its functioning properly,
It's Sad to hear Tht You are From Ukraine, What is the situation on ur area 😪🤐 Praying for Ukraine 🙏
Glad to hear that you fixed things! And thank you for the support. You can join my Discord to find out more about my current situation - discord.gg/dCJBpe2meg
Hey Tamara, it looks like it doesn't work when there's only 1 tile sized object, it's placing it there and event filling it, but detecting the tile using the "CanBePlaced" doesn't work for me, does it work for you?
I mentioned in the video that the size has to be increased by 1 on both axes because when it is calculated it is smaller. Try debugging and see if the size is actually 1 and not 0
Can you do a tutorial on how to "save" a grid (as an array or JSON) and load it later? So players can save their game?
Thank you for the suggestion. I'll think about making such video.
Hello :) How would I go about allowing the building to follow the mouse until I place it down? Im having trouble with using Left Mouse to click on UI to Initilize the Build as well. Thanks!!
Hey there! Following the mouse would be easy, just get the mouse position in the update method, perform some raycasting like I did in this tutorial to get the world position, and assign the new position to the transform of an object you want to move. As for the left mouse clicks, I can't really help with that, but I suggest you try asking in my discord server, maybe somebody there knows. Link to join - discord.com/invite/dCJBpe2meg
@@TamaraMakesGames Thanks for the quick reply :) Ill stop by the discord for sure!
how can i set that the building will spawn at my mouse position after i clicked a button or pressed a key??
Hi there! You have to modify the initialize with building method in the grid building script. Instead of vector3 zero pass the mouse position in world space
@@TamaraMakesGames I tried something and changed so that the object spawns on the the mousePosition but not on my terrain, it spawns on the canvas
My Code:
public Vector3 SnapCoordinateToGrid(Vector3 position)
{
Vector3Int cellPos = gridLayout.WorldToCell(position);
position = grid.GetCellCenterWorld(cellPos);
return position;
}
#endregion
#region Building Placement
public void InitializeWithObject(GameObject prefab)
{
Vector3 mousePos = Input.mousePosition;
GameObject obj = Instantiate(prefab, mousePos, Quaternion.identity);
objectToPlace = obj.GetComponent();
obj.AddComponent();
}
I really need the 2d version for this?
excluding the codemonkeys one, i cant find it anywhere
2D version of this tutorial made by me - ruclips.net/video/gFpmJtO0NT4/видео.html
Hello, thank you for the video it really helped me but I have a question. When we destroy the prefab using echap, the white tiles don't disapear. How can we erase them ?
Hi there! I'm glad you found my video helpful.
I think you're not calling the erase method after destroying a building. In the building system script should be a method for clearing tiles on some territory.
What if there is a wall and you place something on wall? it use y and z axis ?
Depends on how your axes are rotated and which wall it is. If your y axis points upward your coordinates can be on x and y on one wall, and y and z on the other wall.
@@TamaraMakesGames thank you, you are great.
I tried something and changed so that the object spawns on the the mousePosition but not on my terrain, it spawns on the canvas. How can i fix it?
My Code:
public Vector3 SnapCoordinateToGrid(Vector3 position)
{
Vector3Int cellPos = gridLayout.WorldToCell(position);
position = grid.GetCellCenterWorld(cellPos);
return position;
}
#endregion
#region Building Placement
public void InitializeWithObject(GameObject prefab)
{
Vector3 mousePos = Input.mousePosition;
GameObject obj = Instantiate(prefab, mousePos, Quaternion.identity);
objectToPlace = obj.GetComponent();
obj.AddComponent();
}
You didn't convert your mouse position to world point. And it is better done with ray casting in 3d. I featured this function in the grid building script
Привет Тамара! Спасибо за видео!
My prefabs are instantiating at a fixed position always and not at the point where i click
That's actually expected behavior.
You have to click on your prefab (triggering OnMouseDown) and drag it (Triggering OnMouseDrag) to drag it to the desired position.
İ wanted to remake this script, but İ get an error by "[SerialzeField] private Tilemap MainTilemap", its saying that Tilemap can't be found, how can İ fix it
Did you import the tilemap package into your project?
@@TamaraMakesGames İ imported 2D Tilemap Editor, did İ have to import other packages?
@@ord-a28 That should be enough. You have to import tilemaps in the script where you're using them. Like this
using UnityEngine.Tilemaps;
@@TamaraMakesGames İt worked, thank you.
Hi tamara are you starting from scratch ?
Hi, there! Yes, in this tutorial I am using a new project, it's not part of a series
@@TamaraMakesGames thank you
Great video!
Thanks!
Nice video :) How do we make irregular grids? Would it be possible to create a realistic cadastre map?
Hi there! Thank you!
As of such maps, this particular system can't do that because it is based on the Unity tilemaps which don't have such option. But it is a very interesting topic so maybe I'll look into it 🙂
Where can we get White Tile file?
I have the same question. They are missing somehow
do not follow this tutorial. There are newer method which support more. Watching this will not waste your time though, you will learn how to configure unity even if it do not help you for this task.
Day 1 in the life of a senior game developer
What's the 'Grid.cs'
A Unity class that has the methods to convert coordinates from world space to grid cells
Drag working fine but not spacebar thing. Esc working fine.
Maybe next time don't skip some isntructions like how to create a tile from a sprite, it's just appearing like that for you but for beginners it was a nightmare to figure what it was
you are aweesomee!!
Nice video!
Thank you!
Hi Tamara, How are you, I suggest you make a series of RTS games, knowing that there is no content on RUclips to prepare a course for it. Even if it is paid, I will buy it to support you. I hope you will fulfill my request and be 3D
Hey there! Thank you for your suggestion I will definitely take it into consideration. If I were to make such tutorial series, what features are you interested in?
Good job
Thank you!
Where is Placeable Obj code?
I think i love you :D fantastic !
Great video and code Tamara, I am a Patrone sponsor! One thing, I do not know if I made anything wrong but when I place a house/object I color the tiles but when I then move it those colored tiles remain. Another thing, the second time I place an object it cannot be moved anymore (after first placement I can move it one more time), last thing, when I move an object it does not become the current object so when I rotate it then another object rotates instead. What can I do?
Hello, please reach out to me on Patreon or even better on my Discord server in a dedicated patrons channel and I'll try to help you
Nice!
Thanks!
You shouldn't name both private variables and public properties with CamelCase. Private should start with _or something else otherwise it's way too hard to debug. You'll thank yourself later
Hi!)
You have very cool videos.
I wish I could subscribe to patreon(
Is there any other way I can pay for my subscription and get access?)
Kool
Thanks!
can you please help me for a project?
If you're talking about a freelance offer, I don't take those at the moment. If you just want to get help implementing t he system in your project you can come up to my Discord server - discord.gg/dCJBpe2meg
@@TamaraMakesGamesWe can met on wat app because discord have problem don't work and im not undestand if i need pay you if you doing as job programming cs?
I am not taking such jobs at the moment
Can you givme facebook or Wat app so i can send project discod dont work me
I love you
Unity now supports 2d and ar and all kinds of other things so we don't use unity3d as a term anymore really lol
it's just unity now lol
Emphasis was on 3D since this is a grid building system for 3D projects in Unity
your tutorials are much too fast and suddenly we do not understand
I'm sure everything I wanted to know was there, but you went way too fast for a tutorial.
idk but its not working
I didn't understand shit
Unity grid system not god at all. I suggest you to write your own.
A lot of people think so but it's actually very helpfull if you know how to use it 🙂
The hardest tutorial videos I've ever watched in my life are yours, the code structure is already bad and you explain very incompletely as if you bought the codes from someone else and didn't write them yourself.
Very good tutorial, but are you looking for a husband?
Thanks, but I already found one 😁
You are fit! lol
weirdo
Fix your squinty eyes
Are you single? :)
No :)
Instagram?
I am not on Instagram. I have a discord server though. Here is a link to join - discord.gg/dCJBpe2meg
@@TamaraMakesGames Joined 😊