- Home /
Up to date Unity building placement code/tutorials?
Hey guys, I'm searching around but does anyone anyone know where I can find up to date code or tutorials on building placement ( the kind you have in RTS' and city builders )? If it also included details on how to snap building to a grid that would be great.
I've found lots of old tutorials but a lot of these date back to 2012 and the people who made them never bothered updating their code. It would be great if you could point me towards an example code or tutorial that actually works with the current version.
Why wouldn't the old tutorials notwork with the new Unity versions anymore? It's still C# so snapping GameObjects to a grid is as simple as before. What have you tried so far yourself? Hint: You would need Physics.Raycast to get the cursor position, and $$anonymous$$athf.RoundToInt to snap the selected building to the grid.
lol Well I'm just re$$anonymous$$ded of the struggle I had with following an out of date platformer tutorial and finding it much easier when looking at 2015 stuff. The problem is when I say these tutorials are old, I mean really old like 2009 and so on so if there were an up to date tutorial it would just save a lot of fussing around.
I get what you're saying, I guess I'll have to poke around again, either that or I just need a better understanding of the code which is more likely.
I made a thread on Unity detailing some of the fixes I found and so on for any problems you might encounter making RTS' plus links to a bunch of tutorials.
http://forum.unity3d.com/threads/best-way-to-implement-rts-style-building-placement.373867/
Hope it helps, the biggest problem I had was not understanding Pivot points/centres ( whatever you want to call them ) which drastically affects how your code interacts with GameObjects in the Unity Engine.
After understanding exactly how all that work all the code worked fine, this should prevent a lot of headaches when people are looking up stuff for RTS' and don't understand why their code isn't working right even though there are no errors popping up.
Answer by Lethn · Jul 13, 2015 at 01:37 PM
loooool!
My bad, completely my bad, what had happened was that I had written out this code and tried following a tutorial during a heatwave. So my brain was so screwed that I wasn't concentrating on what I was doing, just by going through it again I have fixed several errors.
Why is it you sometimes only solve a problem after you've written down a question? Anyway, I'm down to one error now but it will be an easy fix.
Your answer
Follow this Question
Related Questions
Minecraft like building? 2 Answers
How to make a grid and able to place buildings on? 0 Answers
Add game building items to dropdown list? 1 Answer
unity - place objects by format 1 Answer
Grid system visualization 1 Answer