Just wanted to add, that I think it would be better to change the OnTriggerEnter method to OnTriggerStay. The reason is because by default, lets say you place down two objects next to each other and try to place down a third object inside. Of course you can't place it, because its in two colliders, however, if you move the object out of one of those, but still inside another, you will be able to place it, because the bool canPlace will switch to true because the object just left one of the colliders which sets of OnTriggerExit. The problem is that it is still in another collider and the bool only changes to false whenever we enter a collider, not when we are in a collider. OnTriggerStay fixes that, as it checks every frame if our collider is in another collider, not when it enters. Hope this helps someone.
@Brenda-tv8lp9 ай бұрын
Hi tanks so much for the video!!! do you have the script uploaded somewhere? the link for TEXT VERSION in description doesnt work :/
@ErenBR562 Жыл бұрын
Hello, this tutorial is helping me a lot! But, I have a question: What can I do to prevent my object from overlapping the other? Thanks!
@epic-orchestras2 жыл бұрын
Hey, do you know how to make a hexagon grid with that?
@ludoremstudios2 жыл бұрын
A hexagon grid is probably a little more complicated and won't use just rounding I think. You might be able to find some tutorials on a hexagon grid that could be implemented into this building system though! Sorry. Thank you for watching!
@coding_game Жыл бұрын
love you best tutorial❤
@NotCadd2 жыл бұрын
Please continue this series. I need help with selecting the object and moving it once placed.
@ludoremstudios2 жыл бұрын
That is planned for the next tutorial, once I get around to making it.
@omerhzl4237 Жыл бұрын
Great video! Thanks for these tuts
@mahersabit9265 Жыл бұрын
great tutorial and everything, just one question, how can we get the original material back, like after placing it, instead of it being blue it becomes the meshs original material, unless we have to add each assets material into the array(which i doubt its the way to go). also thank you for the comments for helping know that i needed to add the check placement script to the prefabs
@ludoremstudios Жыл бұрын
There are several other comments on these videos that describe how to do what you need, check for people asking a similar question. It has to do with dynamically changing the third material in the array to the material of the object.
@stav3483 ай бұрын
hey, I want to implement the same thing. did you end up finding a solution? I can't find it in the comments.
@praveen48382 жыл бұрын
Thank you for the great tutorial 🤗
@ludoremstudios2 жыл бұрын
Glad it was helpful!
@swalscha2 жыл бұрын
Useful tutorial, thank you!
@ludoremstudios2 жыл бұрын
Glad it was helpful!
@antondeleon3822 жыл бұрын
Hi! Is there a way to cancel the pending building if you want to? Thanks!
@ludoremstudios2 жыл бұрын
Of course! I honestly thought this was covered in the video, but it probably wasn't. Simply add something like if(Input.GetMouseButtonDown(2)){ Destroy(pendingObject); pendingObject = null;} In the update under the if(pendingObject!=null) conditional. Hope this helps, and thanks for watching!
@antondeleon3822 жыл бұрын
@@ludoremstudios Thank you so much! I found another solution but will definitely give this one a try! Thank you!
@مؤيدالعبادي-س4ح2 жыл бұрын
I put the checkPlacement script on the gameObject and also put the materials in their correct position and when I run the game everything works correctly but there is an error in this line (pendingObject.GetComponent().material = materials[0]) says Object references not set to an instance of an object How can I solve this problem and the second thing I want is how can I switch the game from mouse to touch on the mobile
@ludoremstudios2 жыл бұрын
Thanks for watching! This is actually an error on my part, but it is a really simple fix. Simply move where you call "UpdateMaterials()" in the update method from the bottom to the top. It has to do with the order in which everything happens, so if UpdateMaterials() is called last it will be called after you place the object, which means there is no object to update! So if you call it first, you can ensure there is always a pending object.
@مؤيدالعبادي-س4ح2 жыл бұрын
@@ludoremstudios Thank you ❤️
@user-xf1ho9lt2t Жыл бұрын
I've read the comments and tried but once the object is placed near the pre-mounted object nothing happens, it should change color to red but it doesn't
@javii94182 жыл бұрын
Why is the prefab cut in half when placed on the grid?
@ludoremstudios2 жыл бұрын
The origin of the prefab is where the transform is. So for a cube, the transform is in the middle of the cube. And when we set the transform of the cube to a spot on the ground, the center is moved to that spot so half is below the ground. If you were using custom models made in blender, you can change the origin of a model to be somewhere lower so you can see the whole model.
@snehakaimal7529 Жыл бұрын
how to save and load the placement of the prefabs ?
@ludoremstudios Жыл бұрын
In my game I used an asset called Easy Save 3. It was extremely helpful in figuring out saving. Saving systems for games like this are very complex.
@mafioznik1487 ай бұрын
helps a lot, thanks!
@hendrakartanegara17312 жыл бұрын
Awesome tutorial bro ... Thanks A Lot. How may years you learn Unity c# ?
@ludoremstudios2 жыл бұрын
I have been doing Unity for probably almost 3 years now? But before that I did do other coding things here and there which probably helped me with understanding the logic of it all. Thanks for watching!
@hendrakartanegara17312 жыл бұрын
@@ludoremstudios great .. , btw im from Indonesia .. the market of user mobile in our country is very huge. maybe sometimes we can work together
@whytho22852 жыл бұрын
i get an error " Index outside the bounds of the array BuildingManager.UpdateMaterials ()"
@noam26382 жыл бұрын
you probably haven't added the 3 materials into the list in the building manager script
@ludoremstudios2 жыл бұрын
Yeah, you probably need to add the materials to the array in the inspector, like @Noam said
@ticketforlife21032 жыл бұрын
Can you make tutorials for VR? Is ot the same as 3D?
@ludoremstudios2 жыл бұрын
I don't even have a VR headset myself, let alone know how to make a VR game in Unity. If you could figure out a way to get raycasts to come from the hands or something, then change the building input from the mouse to the controllers then it would probably still work? I don't know how the UI works in Unity VR so you would probably have to make a different building menu as well.
@illusion65102 жыл бұрын
Great Tutorial! but for some reason if you place many objects close to eachother you can start placing them in one another? any way to fix this?
@ludoremstudios2 жыл бұрын
I think there is a solution, I found it on my discord server. I *think* you just remove else { _buildingManager.canPlace = true; } from the OnTriggerEnter() I am not 100% sure, but let me know if that works!
@illusion65102 жыл бұрын
@@ludoremstudios I never saw any Else functions in CheckPlacement?
@ludoremstudios2 жыл бұрын
It may be because we changed other parts of the script, lemme compare and stuff. Ok I went back and looked at the discord conversation, and that person I think added the else statement. Try changing OnTriggerEnter() to OnTriggerStay() for me and tell me if that works!
@illusion65102 жыл бұрын
@@ludoremstudios It worked! I have tried for so long to get an working placement system! all have failed except yours! thanks, you earned yourself a sub :) definetley underrated
@ludoremstudios2 жыл бұрын
Thanks a ton! Honestly people keep asking for more building system tutorials but I don't know what to do for the next module, what do you think I should do?
@trustjacket31422 жыл бұрын
it worked perfectly thank you so much can you make a video about saving and relaoding the placement with playerpref maybe ;)
@ludoremstudios2 жыл бұрын
Maybe! That's a good idea, but saving instantiated objects is a little tougher, I use Easy Save 3 in my projects.
@madmaxdx33262 жыл бұрын
please continue
@ludoremstudios2 жыл бұрын
If you have any ideas for another tutorial please do tell!
@jasithiss2 жыл бұрын
My "CanPlace" and "CantPlace" materials go pink, Im guessing its bc they're transparent?
@ludoremstudios2 жыл бұрын
I dont see why that would cause an issue, has your project recently been upgraded to a different Render Pipeline? If so you need to upgrade the materials. Or try a different shader, I dont really know if those aren't it. Google is your friend.
@gunst39362 жыл бұрын
you should make de next tutorial about how to remove and how to cancel the pendingObject
@ludoremstudios2 жыл бұрын
Yep! I plan on making the next tutorial this weekend and it will include selecting, deleting, and canceling placement.
@ROEN.MUSIC.OFFICIAL2 жыл бұрын
need help at //buildObject.GetComponent().material = materials[2]; buildObject = null; how can i get the original material back from the prefab?
@ludoremstudios2 жыл бұрын
Are you saying you want a different material for each prefab? Well, you could put in your select method materials[2] = objects[index].GetComponent().material; (Untested) Let me know if this works at all, and if it doesn't I can actually pull up the project and test something for you.
@Santanu_Pal2 жыл бұрын
@@ludoremstudios materials[2] = pendingObject.GetComponent().material; please use this line instead of "object[index]........." It works!!!
@ludoremstudios2 жыл бұрын
@@Santanu_Pal Glad you found something. I am pretty sure that the line I wrote should work as long as you put it in the SelectObject() method, but what you wrote should also work. Glad you figured it out!
@mahersabit9265 Жыл бұрын
@@ludoremstudios thanks! btw, instead of .material; it should be .sharedMaterial; well thats what worked for me anyway😅
@noahhoffman45532 жыл бұрын
Can you please make a system so I can build on top of other blocks thanks so much for making these videos it is helping a lot
@ludoremstudios2 жыл бұрын
Well you could just change the layer mask to include the layer your prefabs are on, so it should just be a matter of opening the layer mask variable and clicking "default". But this will cause a bug, so you will need to change the layer if the object is held, so I think something in the select method like pendingObj.layer = (layer other than default or ground) then in your place method pendingObj.layer = 0; Hope this helps! If you have any more trouble join my discord server so I can help you easier.
@ludoremstudios2 жыл бұрын
And also for this to work properly you should probably turn off the checking placement module.
@noahhoffman45532 жыл бұрын
Thanks a lot :)
@jonathan3122 жыл бұрын
I followed the instruction and it didn't work. I found out you didn't mention that we need to put the script onto the prefabs. Anyway, love the tutorial. I don't see much video on building game. Appreciate the work.
@ludoremstudios2 жыл бұрын
Oh you are right! I can't believe I didn't notice that in editing. Thank you for watching!
@AndyHendriks4 ай бұрын
Hero! I couldnt figure out what went wrong, this fixed it!
@bafidacoder2 жыл бұрын
when i check if can place or not it sometimes doenst work
@bafidacoder2 жыл бұрын
Havent expected you to see my comment ! Ty! After like the 2nd or the 3rd object placed it doesnt work anymore..i can place objects anywhere
@ludoremstudios2 жыл бұрын
Try changing OnTriggerEnter to OnTriggerStay, that might work, but your issue could be something new.
@bafidacoder2 жыл бұрын
@@ludoremstudios i will thank you!!
@bafidacoder2 жыл бұрын
@@ludoremstudios It worked!!! thanks!
@kristiyanaleksiev84032 жыл бұрын
🙇♂️🙇♂️🙇♂️
@ludoremstudios2 жыл бұрын
Thanks for watching, hope it helps!
@atharvagurav9492 жыл бұрын
Color not changing :{
@ludoremstudios2 жыл бұрын
Hi! Thanks for watching. Did you add the script onto all the prefabs and assign the variables, and is the method being correctly called in the script?