- Home /
Sims like building script, picture and webplayer included
Hi,
Im currently doing game , and one element on that game is building rooms. Try this webplayer to see my current progress. Webplayer link HERE
As you can see, you can build "walls" (way too big ) by clicking any free tile on grid. But im looking for similar building system what sims games has. Check this picture
First player click on any tile edge on game, see A. then player will move mouse cursor to the B, and there appears"ghost" wall between point A and B , if player clicks second time, real wall appears.
How to do it? I have tried to find a logic behind this but looks like i cant figure this out without help. Im not asking that you write code to me , im asking you show me the way or give idea how to continue!
Please, help me :(
Yes indeed i have 2 prefabs for walls , and marker is underwork, its not problem. But now main problem is how i draw that path from point A to point B and how to allways snap build marker on corner of tile?
I hope you guys can give answers !
Answer by roamcel · Oct 08, 2011 at 06:33 AM
My approach to this would be to actually use two different classes for the 'wall'. The first class is the 'ghost wall', and the second one is 'real wall':
click once, place construction marker, enter 'ghost wall mode' (something like just toggle keeping your mouse down in your app)
you actually create a rectangle of ghost prefabs (could even just be a transparent version of the 'real' prefab) from the 'marker' up to the mouse cursor
when you click again, you copy the 'path' of ghost wall to a path of real walls, so basically you can even possibly make both walls subclasses of 'wall'. then exit ghost mode.
Answer by TheKusabi · Jun 22, 2013 at 01:50 AM
A* path finding will allow you to build the walls from point a to point b. As for snapping the marker, you can either set the XYZ to that of the tile, or just round the number to the nearest multiple of the grid's cell-size.
Hope you get it working, I'm currently doing a lot of research into the elements of a Sims-like game.
Your answer
Follow this Question
Related Questions
What is wrong with this? 1 Answer
A node in a childnode? 1 Answer
Variables correct in editor, But being reset in build? 0 Answers
Distribute terrain in zones 3 Answers
New C# scripts fail to build 2 Answers