Building System Module #1 - Checking Placement!

  Рет қаралды 11,328

Ludorem Studios

Ludorem Studios

Күн бұрын

Пікірлер: 75
@jasgreipen2575
@jasgreipen2575 7 ай бұрын
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-tv8lp
@Brenda-tv8lp 9 ай бұрын
Hi tanks so much for the video!!! do you have the script uploaded somewhere? the link for TEXT VERSION in description doesnt work :/
@ErenBR562
@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-orchestras
@epic-orchestras 2 жыл бұрын
Hey, do you know how to make a hexagon grid with that?
@ludoremstudios
@ludoremstudios 2 жыл бұрын
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
@coding_game Жыл бұрын
love you best tutorial❤
@NotCadd
@NotCadd 2 жыл бұрын
Please continue this series. I need help with selecting the object and moving it once placed.
@ludoremstudios
@ludoremstudios 2 жыл бұрын
That is planned for the next tutorial, once I get around to making it.
@omerhzl4237
@omerhzl4237 Жыл бұрын
Great video! Thanks for these tuts
@mahersabit9265
@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
@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.
@stav348
@stav348 3 ай бұрын
hey, I want to implement the same thing. did you end up finding a solution? I can't find it in the comments.
@praveen4838
@praveen4838 2 жыл бұрын
Thank you for the great tutorial 🤗
@ludoremstudios
@ludoremstudios 2 жыл бұрын
Glad it was helpful!
@swalscha
@swalscha 2 жыл бұрын
Useful tutorial, thank you!
@ludoremstudios
@ludoremstudios 2 жыл бұрын
Glad it was helpful!
@antondeleon382
@antondeleon382 2 жыл бұрын
Hi! Is there a way to cancel the pending building if you want to? Thanks!
@ludoremstudios
@ludoremstudios 2 жыл бұрын
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!
@antondeleon382
@antondeleon382 2 жыл бұрын
@@ludoremstudios Thank you so much! I found another solution but will definitely give this one a try! Thank you!
@مؤيدالعبادي-س4ح
@مؤيدالعبادي-س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
@ludoremstudios
@ludoremstudios 2 жыл бұрын
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ح
@مؤيدالعبادي-س4ح 2 жыл бұрын
@@ludoremstudios Thank you ❤️
@user-xf1ho9lt2t
@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
@javii9418
@javii9418 2 жыл бұрын
Why is the prefab cut in half when placed on the grid?
@ludoremstudios
@ludoremstudios 2 жыл бұрын
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
@snehakaimal7529 Жыл бұрын
how to save and load the placement of the prefabs ?
@ludoremstudios
@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.
@mafioznik148
@mafioznik148 7 ай бұрын
helps a lot, thanks!
@hendrakartanegara1731
@hendrakartanegara1731 2 жыл бұрын
Awesome tutorial bro ... Thanks A Lot. How may years you learn Unity c# ?
@ludoremstudios
@ludoremstudios 2 жыл бұрын
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!
@hendrakartanegara1731
@hendrakartanegara1731 2 жыл бұрын
@@ludoremstudios great .. , btw im from Indonesia .. the market of user mobile in our country is very huge. maybe sometimes we can work together
@whytho2285
@whytho2285 2 жыл бұрын
i get an error " Index outside the bounds of the array BuildingManager.UpdateMaterials ()"
@noam2638
@noam2638 2 жыл бұрын
you probably haven't added the 3 materials into the list in the building manager script
@ludoremstudios
@ludoremstudios 2 жыл бұрын
Yeah, you probably need to add the materials to the array in the inspector, like @Noam said
@ticketforlife2103
@ticketforlife2103 2 жыл бұрын
Can you make tutorials for VR? Is ot the same as 3D?
@ludoremstudios
@ludoremstudios 2 жыл бұрын
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.
@illusion6510
@illusion6510 2 жыл бұрын
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?
@ludoremstudios
@ludoremstudios 2 жыл бұрын
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!
@illusion6510
@illusion6510 2 жыл бұрын
@@ludoremstudios I never saw any Else functions in CheckPlacement?
@ludoremstudios
@ludoremstudios 2 жыл бұрын
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!
@illusion6510
@illusion6510 2 жыл бұрын
@@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
@ludoremstudios
@ludoremstudios 2 жыл бұрын
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?
@trustjacket3142
@trustjacket3142 2 жыл бұрын
it worked perfectly thank you so much can you make a video about saving and relaoding the placement with playerpref maybe ;)
@ludoremstudios
@ludoremstudios 2 жыл бұрын
Maybe! That's a good idea, but saving instantiated objects is a little tougher, I use Easy Save 3 in my projects.
@madmaxdx3326
@madmaxdx3326 2 жыл бұрын
please continue
@ludoremstudios
@ludoremstudios 2 жыл бұрын
If you have any ideas for another tutorial please do tell!
@jasithiss
@jasithiss 2 жыл бұрын
My "CanPlace" and "CantPlace" materials go pink, Im guessing its bc they're transparent?
@ludoremstudios
@ludoremstudios 2 жыл бұрын
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.
@gunst3936
@gunst3936 2 жыл бұрын
you should make de next tutorial about how to remove and how to cancel the pendingObject
@ludoremstudios
@ludoremstudios 2 жыл бұрын
Yep! I plan on making the next tutorial this weekend and it will include selecting, deleting, and canceling placement.
@ROEN.MUSIC.OFFICIAL
@ROEN.MUSIC.OFFICIAL 2 жыл бұрын
need help at //buildObject.GetComponent().material = materials[2]; buildObject = null; how can i get the original material back from the prefab?
@ludoremstudios
@ludoremstudios 2 жыл бұрын
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_Pal
@Santanu_Pal 2 жыл бұрын
@@ludoremstudios materials[2] = pendingObject.GetComponent().material; please use this line instead of "object[index]........." It works!!!
@ludoremstudios
@ludoremstudios 2 жыл бұрын
@@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
@mahersabit9265 Жыл бұрын
@@ludoremstudios thanks! btw, instead of .material; it should be .sharedMaterial; well thats what worked for me anyway😅
@noahhoffman4553
@noahhoffman4553 2 жыл бұрын
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
@ludoremstudios
@ludoremstudios 2 жыл бұрын
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.
@ludoremstudios
@ludoremstudios 2 жыл бұрын
And also for this to work properly you should probably turn off the checking placement module.
@noahhoffman4553
@noahhoffman4553 2 жыл бұрын
Thanks a lot :)
@jonathan312
@jonathan312 2 жыл бұрын
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.
@ludoremstudios
@ludoremstudios 2 жыл бұрын
Oh you are right! I can't believe I didn't notice that in editing. Thank you for watching!
@AndyHendriks
@AndyHendriks 4 ай бұрын
Hero! I couldnt figure out what went wrong, this fixed it!
@bafidacoder
@bafidacoder 2 жыл бұрын
when i check if can place or not it sometimes doenst work
@bafidacoder
@bafidacoder 2 жыл бұрын
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
@ludoremstudios
@ludoremstudios 2 жыл бұрын
Try changing OnTriggerEnter to OnTriggerStay, that might work, but your issue could be something new.
@bafidacoder
@bafidacoder 2 жыл бұрын
@@ludoremstudios i will thank you!!
@bafidacoder
@bafidacoder 2 жыл бұрын
@@ludoremstudios It worked!!! thanks!
@kristiyanaleksiev8403
@kristiyanaleksiev8403 2 жыл бұрын
🙇‍♂️🙇‍♂️🙇‍♂️
@ludoremstudios
@ludoremstudios 2 жыл бұрын
Thanks for watching, hope it helps!
@atharvagurav949
@atharvagurav949 2 жыл бұрын
Color not changing :{
@ludoremstudios
@ludoremstudios 2 жыл бұрын
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?
Building System Module 2 - Selection!
13:44
Ludorem Studios
Рет қаралды 7 М.
Building a Camera Controller for a Strategy Game
17:48
Game Dev Guide
Рет қаралды 199 М.
Почему Катар богатый? #shorts
0:45
Послезавтра
Рет қаралды 2 МЛН
УЛИЧНЫЕ МУЗЫКАНТЫ В СОЧИ 🤘🏻
0:33
РОК ЗАВОД
Рет қаралды 7 МЛН
БОЙКАЛАР| bayGUYS | 27 шығарылым
28:49
bayGUYS
Рет қаралды 1,1 МЛН
Learning C# In A Week... Otherwise I Fail University
9:04
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,4 МЛН
Level 1 to 100 Science Experiments
15:53
Hafu Go
Рет қаралды 19 МЛН
3D Tilemap in Unity
3:54
Vector Bread
Рет қаралды 163 М.
I Beat Minecraft From One Grass Block
35:27
Beppo
Рет қаралды 7 МЛН
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 803 М.
Master Grid Placement in Unity 2022 P1 - Calculating Cell Position
12:05
Sunny Valley Studio
Рет қаралды 118 М.
Making a Game With C++ and SDL2
8:14
PolyMars
Рет қаралды 1,7 МЛН
Почему Катар богатый? #shorts
0:45
Послезавтра
Рет қаралды 2 МЛН