Coder Social home page Coder Social logo

Comments (7)

Seanba avatar Seanba commented on June 22, 2024

Hi there. I suggest using Tiled's automapping features in combination with
a Tiled2Unity custom importer. In Tiled, you can have the automapping place
Objects in an Object Layer. These objects will be exported to your Unity
project as GameObjects with whatever custom properties you need. You would
then write a custom importer to process those GameObjects in whatever way
suits you -- perhaps as nodes in an A* graph.

It will take a little bit of work but it's totally doable. I've thought of
adding this as a feature before but I doubt I could make it generic enough
for most games. (Pathfinding needs is actually one of the reasons I made
Tiled2Unity to be expanded through the use of custom importers.)

On Sat, Mar 26, 2016 at 11:07 PM, hsdk123 [email protected] wrote:

Hi, I've been using Tiled2Unity for my map imports. Things were great, but
now I need to start implementing path searches from one part of the map to
another (without colliding with any of the colliders), but this seems very
difficult with the current map import method as the maps are just saved as
textures instead of tiles (or any form of nodes).

Do you have any recommendations on how A* could be implemented on top of
the Tile2Unity import file? If this currently seems undoable, it would be
great if an update could be made to make this possible.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#32

from tiled2unity.

hsdk123 avatar hsdk123 commented on June 22, 2024

Hi Sean, thanks for the reply. I get the feeling that having a checkbox option of saving all tiles as individual game objects would be more than fine for a lot of cases (with just an added warning message saying that we can get O(n2) performance issues).

I'm trying the automapping recommendation for the moment though (following the post here: http://www.seanba.com/getting-tile-information.html), but I don't quite understand how the custom importer works - more specifically, I don't quite know where I should be putting the file, and how I should be incorporating it into the import process. Is there a step by step tutorial for this by any chance?

from tiled2unity.

hsdk123 avatar hsdk123 commented on June 22, 2024

I'm also realising that with the automapping feature, the auto added tiles, after the regular import, are also just imported as 1 large game object like the other tiles. Is this supposed to be happening, or have I misused the automapping feature?

Here's the map I'm currently testing with the rules included (test_rooms.txt)
The auto added tiles are placed in the 'Graph' layer.

maps-hsdk.zip

from tiled2unity.

Seanba avatar Seanba commented on June 22, 2024

I can't open TMX files without the images that go with them but eyeballing
the rule1.tmx file in a text editor it looks like your output is another
tile. I'm suggesting you output not a tile to a Tile Layer but an object to
an Object layer. These get imported as GameObjects on the Unity side of
things.

For custom importers I talk about them a bit here:
http://www.seanba.com/megadadadventures.html

I don't think the option of exporting every single tile as an object is a
good idea. Even for small maps your GameObjects will quickly grow in number
past tens of thousands of objects. For traditional A* not all tiles are
going be used anyhow and some users are going to want to use nav meshes for
pathfinding instead (in this case, using the generated PolygonCollider2D
objects may be a better approach).

(BTW, you may want to use TSX files so that you don't have to re-import the
15 or so tilesets for every TMX file you work with. Just a thought.)

Best,
Sean

On Sun, Mar 27, 2016 at 1:41 PM, hsdk123 [email protected] wrote:

I'm also realising that with the automapping feature, the auto added
tiles, after the regular import, are also just imported as 1 large game
object like the other tiles. Is this supposed to be happening, or have I
misused the automapping feature?

Here's the map I'm currently testing with the rules included
(test_rooms.txt)
The auto added tiles are placed in the 'Graph' layer.

maps-hsdk.zip
https://github.com/Seanba/Tiled2Unity/files/191040/maps-hsdk.zip


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#32 (comment)

from tiled2unity.

hsdk123 avatar hsdk123 commented on June 22, 2024

Thanks for the quick replies - I'm trying to get the custom importer working, but Unity gives me

Assets/Tiled2Unity/CustomImporter.cs(10,36): error CS0234: The type or namespace name `ICustomTiledImporter' does not exist in the namespace `Tiled2Unity'. Are you missing an assembly reference?

errors. Would you have any idea as to what might be happening?

My custom import script is just the below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using UnityEditor;
using UnityEngine;

[Tiled2Unity.CustomTiledImporter]
class CustomImporter : Tiled2Unity.ICustomTiledImporter
{
    public void HandleCustomProperties(GameObject gameObject,
        IDictionary<string, string> keyValuePairs)
    {
        Debug.Log("Handle custom properties from Tiled map");
    }

    public void CustomizePrefab(GameObject prefab)
    {
        Debug.Log("Customize prefab");
    }
}

from tiled2unity.

Seanba avatar Seanba commented on June 22, 2024

Editor scripts must be in a folder named "Editor".

Assets/Tiled2Unity/CustomImporter.cs (won't compile)
Assets/Tiled2Unity/Editor/CustomImporter.cs (will compile)

... but I recommend you keep your custom scripts outside of the Tiled2Unity
folder and put it somewhere like ...

Assets/YourGameScriptFolder/Editor/CustomImporter.cs

Hope that helps,
Sean

On Sun, Mar 27, 2016 at 2:19 PM, hsdk123 [email protected] wrote:

Thanks for the quick replies - I'm trying to get the custom importer
working, but Unity gives me

Assets/Tiled2Unity/CustomImporter.cs(10,36): error CS0234: The type or namespace name ICustomTiledImporter' does not exist in the namespaceTiled2Unity'. Are you missing an assembly reference?

errors. Would you have any idea as to what might be happening?

My custom import script is just the below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using UnityEditor;
using UnityEngine;

[Tiled2Unity.CustomTiledImporter]
class CustomImporter : Tiled2Unity.ICustomTiledImporter
{
public void HandleCustomProperties(GameObject gameObject,
IDictionary<string, string> keyValuePairs)
{
Debug.Log("Handle custom properties from Tiled map");
}

public void CustomizePrefab(GameObject prefab)
{
    Debug.Log("Customize prefab");
}

}


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#32 (comment)

from tiled2unity.

hsdk123 avatar hsdk123 commented on June 22, 2024

Hi Sean, thanks, I managed to get things working. I feel that the explanation on directories would be a great addition to the wiki though.

I'll close this thread then until perhaps I come across what I feel might be a more generic method to allow for pathfinding using Tiled maps. Thanks for the help!

from tiled2unity.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.