Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Isometric Tilemap 2D Collision bounds

Discussion in '2D Experimental Preview' started by max4260, Sep 28, 2018.

  1. max4260

    max4260

    Joined:
    Mar 6, 2017
    Posts:
    10
    I'm working on a tilemap project that needs pathing (would be great if you could use a navmesh with a procedurally generated tilemap BTW).

    I was using an orthographic tilemap and everything was working great by setting my A* grid to the Tilemap Collider 2D bounds. When making the conversion to isometric it doesn't seem to work. Sizes and the bounds center is all off.

    Anyone have any tips on how to get an isometric tilemap bounds?
     
  2. zulfajuniadi

    zulfajuniadi

    Joined:
    Nov 18, 2017
    Posts:
    117
  3. max4260

    max4260

    Joined:
    Mar 6, 2017
    Posts:
    10
    That's a totally different game object. I'm trying to overlay an a* object over my map and something about the width and height just isnt adding up, though the center point does.

    upload_2018-10-2_9-18-39.png
     
  4. max4260

    max4260

    Joined:
    Mar 6, 2017
    Posts:
    10
    @zulfajuniadi I'm having a heck of a time getting this to work.

    instead of using a bounding box im taking the Tilemap.Size property and then using the tile size i can get something i'm happy with. the new issue is that i cant find the dang center now! any thoughts?

    just wish pathing worked out of the box and then i would be nice and happy.
     

    Attached Files:

  5. zulfajuniadi

    zulfajuniadi

    Joined:
    Nov 18, 2017
    Posts:
    117
    Isn't the center supposed to be the half width and height of the tilemap size? I've also implemented A* on the isometric tilemaps but I'm not using the collider. I've just added a new tilemap layer and mark the tiles as walkable or not with respective costs. Will send you a gif once I'm home tomorrow morning.
     
  6. max4260

    max4260

    Joined:
    Mar 6, 2017
    Posts:
    10
    @zulfajuniadi very appreciated. I'm spending a ton of time on this easy thing. worse is it worked perfect before i switched to isometric.

    my current failed attempt to get the center is:
    Vector center = new Vector(TileMap.CellToWorld(TileMap.size.x / 2, TileMap.size.y / 2, 0));

    Its something silly that's putting it off the course. Would be so much easier if there was a built in bounds or the bounds to the collider worked properly.

    Did you create your own A* or use an asset?

    I'm trying to use: https://arongranberg.com/astar/
    I don't really have a reason other than it's free and works until I feel like the project is far enough to warrant a custom solution.

    I'm really considering making an opensource project that creates a few different types of maps(land, town, cave & dungeon) with A* to help everyone like me out once I get the hang of this.
     
  7. zulfajuniadi

    zulfajuniadi

    Joined:
    Nov 18, 2017
    Posts:
    117
    This is what I've been working on the last couple of weeks:



    Have you tried Tilemap.CellToWorld(tilemapBounds.center) ?

    I've created my own implementation. Just the basic functionalities of multithreading, scanning, and grid searching with traversable / untraversable tiles and weights. Not nearly as complete as the Astar Pathfinding Project by Aron Granberg.

    It's fast enough and only allocates a few bytes per frame (for thread scheduling). The bottleneck right now is rendering (7.5ms) and animator (24ms) @ 3700 agents as profiled inside the editor. 3-5x speedup on windows player builds.



    I'm pretty sure if I were to do this with ECS I could easily have 10,000+ agents running around. Though that would mean that would trade re usability for speed.

    Here's a short explanation video on how it works. Sorry for the background noise for the first 10 seconds or so:



    Do let me know how it goes.
     
    Sylmerria likes this.
  8. max4260

    max4260

    Joined:
    Mar 6, 2017
    Posts:
    10
    @zulfajuniadi Doh, I knew it was something that I should have gotten. Tilemap.CellToWorld(tilemapBounds.center) did the trick. I greatly appreciate the help!!

    Your project looks very cool. Hope to see more of it!
     
    zulfajuniadi likes this.
  9. Pharazone

    Pharazone

    Joined:
    Aug 6, 2018
    Posts:
    7
    Good idea! I'm going to do same thing like you. But here I have a question, how should I do to let the non-walkable buliding auto generic a tilemap layer ? Not by manual editing to add a layer.I am going to make a auto generic tilemap into my games, so th
    ank you.
     
  10. zulfajuniadi

    zulfajuniadi

    Joined:
    Nov 18, 2017
    Posts:
    117
    The Tile class can instantiate a prefab on start so you could probably do it there using tilemap.WorldToCell and passing the instantiated gameobject's transform.position.
     
  11. Pharazone

    Pharazone

    Joined:
    Aug 6, 2018
    Posts:
    7
    Thank you for this. And I still want to know how to make or draw the tile sets you made.Like castles and buildings. Were these made by any tools?