Search Unity

  1. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  6. Unity 2017.3 beta is now available for download.
    Dismiss Notice

[v3.0.1] Isometric 2.5D Toolset

Discussion in 'Assets and Asset Store' started by blackmat, Jan 16, 2015.

  1. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    If 2dtoolkit support Z sorting for tilemap then you can use one IsoObject for tilemap.

    Yes, but not public. You can send your request me to email or here :)
     
  2. fayte0618

    fayte0618

    Joined:
    Dec 4, 2013
    Posts:
    9
    Do you have any tutorials on how to use Tiled and export it to Unity?
     
  3. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    Only video from first post. Do you have any questions? Ask me to email or here :)
     
  4. inZania

    inZania

    Joined:
    Mar 3, 2016
    Posts:
    26
    I'm having some trouble with physics. I've followed the physics tutorial and it works great when I'm moving around on a single tile. But when I try to cross the boundary from one tile to the next, my character is blocked. It seems the edges between tiles block the physics for some reason, so the velocity on the player will not let him cross between tiles. If I "jump", though (increase Z axis) I can jump over the border. Here's a video: http://inzania.com/temp/mg/stepping.mov
    And here's a screenshot of my config:[​IMG]
    [​IMG]
    [​IMG]
     
    Last edited: Mar 16, 2016
  5. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    Hello inZania. It's is normal physics behaviour (plugin can't fix it). You can make one big physics block or plane for floor and big block for stone block.
     
  6. inZania

    inZania

    Joined:
    Mar 3, 2016
    Posts:
    26
    Thank you for the fast reply! I've added a parent GameObject as the collider and it's much better. Now, I'm having some trouble with occlusion.

    First, when I jump, tiles "pop" in front of each other: http://inzania.com/temp/mg/jumping.mov
    Next, sometimes tiles re-sort. Notice how the edge of the grass moves in front/behind the stairs: http://inzania.com/temp/mg/occ.mov

    Have I set something up wrong?
     
  7. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    Show me please bounds and scene hierarchy. If your hero penetrate too much in stone then you can make his bound little bigger than his sprite. Like physics example.
     
  8. inZania

    inZania

    Joined:
    Mar 3, 2016
    Posts:
    26
    Here is my hierarchy. As you can see, I already made the hero bounds bigger than the sprite.
    I think the problem probably has to do with how I'm combining the "plateau" (GameObject) with the child "tile" game objects. Both the plateau and tiles are IsoObjects, and I can't seem to get the settings right. The plateau is 8x2, while the tiles are 1x1 each. Only the plateau has an IsoRigidbody / IsoBoxCollider, so that the player can walk around the plateau as one object.
    [​IMG]
     
    Last edited: Mar 17, 2016
  9. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    No, make physics bound little bigger than Iso Object bounds or vice versa :)

    Also if you want have many sprites in one Iso Object (like "plateau") you should be placed internal sprites in right position relative to each other. (Like physics example "Buildings") Or send me project to email and I'll fix it for you :)
     
  10. inZania

    inZania

    Joined:
    Mar 3, 2016
    Posts:
    26
    Thanks so much. This makes sense now! I thought the tiles would auto-sort, I didn't realize order mattered here. It's working now :)

    I'm running into one more small problem with movement. I'm changing my hero's velocity in the Update() function, just like you show in the tutorial. However, the hero's movement is "jittery" or "stuttering." The velocity is changing between Update() calls and I cannot understand why. For example, in my Update() function, I do this:

    Code (csharp):
    1. Vector3old=isoRigidBody.velocity;
    2. isoRigidBody.velocity=newVector3(2,0,0);
    3. Debug.Log(old+"->"+isoRigidBody.velocity+"("+Time.time+")");
    When this prints out, it says "(1.9,0,0) -> (2,0,0)"

    For some reason, the velocity is decreasing from 2 to 1.9 between Update() calls, causing the "stuttering" where the hero seems to speed up and slow down. My assumption is that some sort of friction or force is decreasing the velocity between frames. But I'm still a bit new to Unity and don't know how to figure out where the bug is :(
     
    Last edited: Mar 18, 2016
  11. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
  12. inZania

    inZania

    Joined:
    Mar 3, 2016
    Posts:
    26
    Perfect! Thanks so much for all your help. The project is really coming along now :)
     
  13. inZania

    inZania

    Joined:
    Mar 3, 2016
    Posts:
    26
    I've built some tools I'd like to share. However, I also have a question about performance. The scripts that come with the Iso2.5D Toolset plugin create a single mesh for an entire Tiled file. I wanted each tile to be separate, so I could have a destructible world, like the screenshot below.

    @blackmat this means a 50x50 world can easily have many thousands of tiles. Will this hurt performance later on?

    [​IMG]

    What I've done is to create my own "spawner" script that can load the Tiled file into objects like this. Check out the source code here. Here's how it works. First, I attach the script to a spawner object on my root. I attach the .tmx file as the asset, set my default pivot points, and also provide some tile prefabs as "templates." These templates already have their box colliders, rigid bodies, etc. setup. They're used to spawn the actual tiles when the .tmx file is imported:
    [​IMG]
    [​IMG]

    My script also understands z-layers. If you set the z-property on a layer in Tiled, it automatically assigns that value to the tiles in that layer. By default, any tile the map will use the first "tile template" provided in the script setup. However, you can also provide a custom property in tiled, called "template," to use a different prefab. This is what lets me create stairs, for example. The stairs have a more sophisticated hierarchy, as you can see above, where there are multiple rigid bodies / colliders as children of the iso object.
    [​IMG]

    The stairs get loaded from the prefab, so they have their own physics set up. Importantly, I only need 1 prefab for each "type" of tile. I could have many different stairs (stone, wood, etc.) all sharing the same prefab, since the script swaps out the asset when it runs:
    [​IMG]

    The total effect is that I can use the Tiled program to have complex physics worlds (video): http://inzania.com/temp/mg/tiled_imported.mov
     
    Last edited: Mar 20, 2016
  14. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    For big number of dynamic tiles you need have chunk system, because many Unity GameObject is very expensive.
     
  15. fayte0618

    fayte0618

    Joined:
    Dec 4, 2013
    Posts:
    9
    Hi! I have a question? I noticed that Layer Collision Matrix adjustment doesn't work on Iso Colliders. How do I make it work?
     
  16. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    Thank you for report! It's my mistake. I'll fix it in a couple of days and send it for you!

    Fast fix for you (IsoFakeObject.cs): http://pastebin.com/RhDdyPHv
     
    Last edited: Mar 28, 2016
  17. lenneth78

    lenneth78

    Joined:
    Jul 2, 2012
    Posts:
    96
    Can you use singleton pattern for found isoworld ? It can improve perf.
     
  18. fayte0618

    fayte0618

    Joined:
    Dec 4, 2013
    Posts:
    9
    Thanks for the fix. It works better now.

    I have another problem, I have this wall object that has an iso box collider set as a trigger. And in order for the trigger to set off I noticed it must have an iso rigidbody. Can't it be the other way around? Where my player contains the iso rigidbody so that I won't have to place rigidbodies on my walls?
     
  19. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    You can store IsoWorld to your game logic singleton (if you need). In the plugin it moment haven't performance problem.
     
  20. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    No, wall not must have a IsoRigidbody (If you use it for trigger) But...What behavior do you want?
     
  21. fayte0618

    fayte0618

    Joined:
    Dec 4, 2013
    Posts:
    9
    Because I have for example 20 walls, and only 1 player. Instead of having 20 iso rigid bodies I can only have 1 for the player. Was just thinking for optimization purposes.
     
  22. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    You can have only IsoBoxCollider for wall. It's ok.
     
  23. lenneth78

    lenneth78

    Joined:
    Jul 2, 2012
    Posts:
    96
    I have problem with runtime creation of IsoObject which lag because of search of IsoWorld. I have already modify plugin with singleton pattern so all good.But I prefer a real plugin modification for futur upgrade.
     
  24. fayte0618

    fayte0618

    Joined:
    Dec 4, 2013
    Posts:
    9
    Yeah I was about to do that but the problem is IsoTriggers are not detected on the walls if it has no rigidbody
     
  25. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    OK! I'll research this moment :)

    Em...I tried this situation and all right if IsTrigger is On. You can send me minimal project to email and i'll fix it.
     
  26. inZania

    inZania

    Joined:
    Mar 3, 2016
    Posts:
    26
    Hi @blackmat, I'm back again and feeling foolish :( I'm trying to simply detect when an object is moused-over or clicked. I've tried adding ` OnMouseOver` or ` OnMouseEnter` to a script on the object, but neither ever fires. Next, I tried doing some raycasting.

    In a normal 3D world, it seems the code would look something like this:
    Code (csharp):
    1. IsoRaycastHit[] iHits = IsoUtils.IsoConvertRaycastHits(Physics.RaycastAll(r));
    2. foreach(IsoRaycastHit iHit in iHits){
    3.   Debug.Log("Hit!"+iHit.rigidbody);
    4. }
    That didn't work (not too surprising; you've explained that the 3D space and the Iso space are different, of course). Next I tried creating a "tracker" (an IsoBoxCollider) that is at the same exact position of the camera. Then I tried this:
    Code (csharp):
    1. IsoRaycastHit isoHit;
    2. Vector3 targetedPosition = isoWorld.MouseIsoPosition();
    3. Vector3 camPos = tracker.GetComponent<IsoObject>().position;
    4. Ray ray = new Ray(camPos, targetedPosition - camPos);
    5. if(tracker.Raycast(ray,out isoHit,float.MaxValue)){
    6.   Debug.Log(isoHit.rigidbody);
    7. }
    This always prints out the tracker itself (never collides with any other object).

    Of course, I could just look at the isoWorld.MouseIsoPosition(). But the problem with this is that it does not take into account Z-layer occlusion. It always returns, say, 1x1x0, even though I might actually be trying to target an object at 0x0x1.
     
    Last edited: Mar 30, 2016
  27. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    Hi, inZania :)
    You can use 2d trigger collider special for raycast and mouse (On your IsoObjects). It's simplest way. Hardest way calculate virtual isometric camera position and start raycast from here to isometric mouse position, but plugin can't it yet :(
     
  28. inZania

    inZania

    Joined:
    Mar 3, 2016
    Posts:
    26
    Ah! I thought that the IsoCollider would provide the `OnMouse___` functions, but I see that I needed to add a 2d box collider w/ a trigger separately :)
     
  29. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    Version 2.3.2
    Bug fixing
    - 'DontDestroyOnLoad' now working with physic objects
    - 'Layer Collision Matrix' fixes
    - Tiled map material bug fix
    Performance tweaks
    - Collision events is disabled by default (add IsoTriggerListener or IsoCollisionListener for get events)
    - 'Cache renderers' flag for IsoObject
    - 'IsoWorld.Instance' for get IsoWorld singleton instance
     
  30. lenneth78

    lenneth78

    Joined:
    Jul 2, 2012
    Posts:
    96
    :):)

    So I need a collider per tile ? It's not heavy ?
     
  31. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    Yes, it's heavy, but you can use it only for objects (buildings, characters and etc) and one collider for floor.
     
  32. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    Snapping in editor mode. Work in progress.
    [​IMG]
     
  33. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    Version 2.4
    - Snapping support for editor
    - Add capsule collider
    - Physic raycast from iso camera support (IsoWorld.RayFromIsoCameraToIsoPoint)
     
  34. lenneth78

    lenneth78

    Joined:
    Jul 2, 2012
    Posts:
    96
    What allows this feature ?
     
  35. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    Physic raycast from "eyes" to mouse point for example. (look new physic example)
     
  36. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    You may send me your feature requests for this plugin and I'll implement them in the next versions :)
     
  37. tomph

    tomph

    Joined:
    Nov 6, 2013
    Posts:
    10
    Hi blackmat. I'm having issues with TriggerEvent in Playmaker. Events are not firing (tags are correct), both ISOBoxColliders are marked as trigger and I have ISOTriggerListener component on both objects.

    I even tried the playmaker actions in Example Scene00 but they do not work. Could you check it for me?

    Thanks
     
  38. tomph

    tomph

    Joined:
    Nov 6, 2013
    Posts:
    10
    Ok, it's working now. I had to add a rigidbody, i think?
     
  39. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    Hi tomph! Yes, trigger events are only sent if one of the colliders also has a rigidbody attached. (this behaviour like standard unity physics)
     
  40. antonincharrier

    antonincharrier

    Joined:
    May 22, 2016
    Posts:
    4
    Hello,
    I hope my question is not stupid.

    I've begun using your tool since not a long time ago. I tried to add Gravity to my GameObjects, and they don't 'fall' on Iso Z axis, but on Iso Y axis... I tried to make the same as you did in the second video, with just two GameObjects to see if I did a mistake in my scene, but it still does the same mistake... I don't know what I'm doing wrong...

    I am a beginner, so I think it is just a stupid error, but I really don't know where it is :(

    Here is a little record:
    https://media.giphy.com/media/hfL6VtXFFkuLm/giphy.gif
     
  41. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    Braza likes this.
  42. antonincharrier

    antonincharrier

    Joined:
    May 22, 2016
    Posts:
    4
    Thanks a lot for the quick reply!
     
  43. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    you are welcome :)
     
  44. Jekel

    Jekel

    Joined:
    Sep 3, 2013
    Posts:
    23
    Hello! is it possible to make a tile top-down type? like this:
    [​IMG]
    Please show an example of your script in action, thank you very much!
     
  45. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    Yes it's possible! :)
     
  46. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    ->Demo<-
     
  47. Jekel

    Jekel

    Joined:
    Sep 3, 2013
    Posts:
    23
    Thank you, but I had in mind the example of the top-down view. But if possible, I am glad)
     
  48. Helipork

    Helipork

    Joined:
    Mar 19, 2015
    Posts:
    2
    Hey,

    I've been using this wonderful plugin for a personal project, and I've just stumbled upon an issue: it doesn't really seem to handle isometric rotation (unless I just haven't found the way to do it). I need to rotate and image from a tile towards another one, at runtime. Is there an easy way to do this using the toolset, or should I look into some geometry notions such as projection?

    Unity Vector2.Angle doesn't really help me, since it returns an angle based on Vector2.zero (and even if it did work, I'd still have to convert the returned angle into an isometric one).
     
  49. blackmat

    blackmat

    Joined:
    Jan 8, 2015
    Posts:
    170
    You can rotate your sprite (if it's child of Iso Object) for example. Also you can make sequence animation for rotation. And also you can use 3d models for rotate all axis.
     
  50. antonincharrier

    antonincharrier

    Joined:
    May 22, 2016
    Posts:
    4
    Hello again!

    I have iso gameobjects with IsoRigidbody and IsoBoxCollider. I want to add functions OnTriggerEnter and OnTriggerExit. It worked well with OnTriggerEnter2D and OnTriggerExit2D without using Iso scripts, but when I converted it to IsoObject, OnTriggerEnter2D didn't work, neither OnTriggerEnter.
    Is there a way to use those functions with your plugin?