After a long time, I made the decision today, to wake up my frozen project. I wanna start from scratch. So the first thing I’ve to do is an infinite grid to place objects.
To bring a picture in your mind: A player starts on a platform with fixed size. He produces the mats for a new platform. If it’s enough resources, he could widen the playable area through the way of adding a platform to the existing one.
Rules:
You just have one object (rectangle) with fixed size at start
You can add rectangles around the first rectangle, so to the north sounth, east and west
You can only add further rectangles to existing sides, not place in empty space in the infinite grid
Every added rectangle must have an unique ID, to interact with it later, call it
Placed rectangles can’t be removed
In the past I copied the mother object and moved it to it’s position, but I think it’s a stupid way.
(Update: I remember now, I placed invisible Objects around the rectangle and on click changed it to a visible rectangle - I’m sure also a silly way!)
Please be patient, cos I’m starting from cratch and I’m afraid I’m not so deep into C# again.
I would use a cloud of data in the form of a dictionary. Each section of a cloud will have an ID, position and type variables, and entities for each direction. When you go to build a direction, you simply ask if that edge has an entity already. If so, you can’t add it. Everything is serializable, so it can be read and written to a disk.
new Dictionary<string, Entity>()
Entity.ToString() == string.Format("{0}-{1}", position.x, position.y)
I could write the whole thing out, but you would not learn from that.
Create a series of prefabs with a script to control each one, then use position elements to give a list of points and rotations for each one. Convert the positioning to XYZ so you can add height to your map.
See my response here:
This concerns how the OP wanted to create a path for vehicles to race on. However the principle of the response is exactly what you are asking for.
Consider that you have a “grid” of elements. Each one leads to a new map part. Instead of giving NWES, you give NWESUD. Giving Z to your coordinate system. Even better… this map leads to “0|1|0” which does not exist, so you can go up a level. Your core Dictionary gives you each part as a string representation, so finding where you can and cannot go is a breeze.
now, next part deals specifically with the link above… each prefab does not HAVE to give NWESUD, it could only give one or some of them. Because each entry point is based off the current tile point. So you are going to have to add position and rotation to your entities.