|
Post by cerulea on Aug 27, 2021 15:23:57 GMT
Hello, been a long time since revisiting this project. I started making a block that can be traveled to on two levels. I converted all tiles to a list which lets me handle logic for choosing top or bottom level. ( this allows me to have walkable bridges across or under also. )
When the search logic branches into checking for the next tile, I simply have a secondary check for if the next tile has a lower walkable tile. Now, this works 80% of the time.( maybe 95%)
I can move normal to lower tiles no issues. Lower to normal no issue. Lower to 2nd story is perfect. Where it breaks is going 2nd story to lower story. It seems that in traverse the prev tile is not set correctly somehow and is null. I added a check and give it a new value if null, simple +1 on the y. This works perfect in some cases, but in some other cases it falls straight down to the lower tile. Sometimes it goes one tile normal then slopes down through the ground to the final point.
Any ideas?
|
|
|
Post by Admin on Aug 30, 2021 12:54:38 GMT
It is likely a logic error in your code. If you want to share, I might be able to help better. It sounds like you're kind of far down this path, but if you want another approach option, you could have each tile specify a list of tile points that they connect to. It would be a bit more setup on the board itself, but would be more flexible (could even do things like portals), and the code would have less complexity as well.
|
|
|
Post by cerulea on Aug 31, 2021 1:16:49 GMT
Interesting, so each tile would have a list of connectable tiles? Do you mean that I would make a reference for all of the surrounding tile when I instantiate them in? Then use that instead of dirs when expanding search? Not sure I follow exactly, might I ask how you would approach that more? I will send a message later with my current setup. Possibly a google drive link.
|
|
|
Post by Admin on Aug 31, 2021 12:43:28 GMT
I was imagining the tiles would have a list of connectable tile locations, that way you can still grab a reference to a tile that doesn't exist yet. If you saved the board as a prefab with all its tiles already instantiated, then you could store a reference directly to tiles though. If I were doing this approach, I would probably add an editor step as a last step which would begin the process by auto-assigning all adjacent tiles as link locations. I could then go through and edit manually by either adding or removing tiles as necessary to handle my special cases. This way you could get handle things like one-way paths, teleporting, jumping gaps, bridges, etc. You are correct, when doing path finding with this kind of a setup, you would look through the list of connected tiles, rather than the array of directions when expanding a search. Ask away
|
|
|
Post by cerulea on Aug 31, 2021 16:33:25 GMT
Ooooooooh, I think that I see the picture a bit more clearly now! So I will keep my board creator as is now, and add a list of connected tiles. Each connection will have the tile Reference needed for each direction, and then for each lvl 2 direction/portal position. The map will be input as a single prefab of all the set up tiles. My geomancer class which can destroy and o change tile types ( that was hard to get working) can then copy the references as needed from there also. Great! I will take this idea and see if I can get it up and running tomorrow!!
|
|
|
Post by nosfouratwo on Aug 28, 2022 20:50:45 GMT
Sorry, I know this is old material and I wouldn't doubt I am just posting into the void on this one, but are you able to explain further on where to begin? Or any material that you could direct me to that might help with this kind of use case.
If I am understanding you would have your Tile game object which would have the Tile script and you would have a script that references linked tiles. Would you add these references to linked tiles in the Tile script or would you want a separate script to handle linked tiles? I would say that I have the coding skills of a college aged toddler and foreign languages were always my worst subject and trying to translate program speak to something actually understandable for me is still a skill I dont quite have, so I apologize if this is something that should be obvious given the above information.
This is my first guess at how this would be approached.
change the Point struct to 3 dimensions and include the tiles x,y,z. then
In the equivalent of my Tile.cs file I would add
public Tile connectedTileNorth;
public Tile connectedTileEast;
public Tile connectedTileSouth;
public Tile connectedTileWest;
as well as change all references to height to pos.z? Would that be in the right ballpark to start?
|
|
|
Post by Admin on Sept 7, 2022 21:37:12 GMT
There are a few things to consider. One is how to save and load levels. If you want simple data like a scriptable object, then you can create a structure that represents a tile by its X, Y, Z as well as its linked tile locations (also X, Y, Z). Another option is to use the board creator to create tiles and then while you are editing the level, you can drag the whole thing into assets as a prefab. This way, you can actually serialize the Tile references directly. The example script you shared above would work in that second option.
The other issue is how to handle working with the multi-level board (pathfinding/tile selection indicator movement etc). When there is only ever one vertical position to worry about, several things were made simpler, and I could simply look in each of the cardinal directions with an offset. Now, you will be looking to traverse between tiles based on the "links" that have been set up on each tile, rather than by direction alone.
|
|