Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Orthello 2D Framework - 100% FREE

Discussion in 'Assets and Asset Store' started by mas, Jul 7, 2011.

  1. Mutain

    Mutain

    Joined:
    Jun 1, 2013
    Posts:
    3
    Hi, i have posted some weeks...months ago about a problem with trimmed sprites.
    Now after this problem becomes so disturbing, that i couldn't continue with my work i took a look at the source code.

    What i found was this function i the OTObject.cs

    Code (csharp):
    1. public Vector2 position
    2.     {
    3.         get
    4.         {
    5.             if (otTransform != null)
    6.             {
    7.                 if (otTransform.parent!=null)
    8.                     return new Vector2(otTransform.localPosition.x - offset.x, (OT.world == OT.World.WorldTopDown2D)?otTransform.localPosition.z - offset.y:otTransform.localPosition.y + offset.y);
    9.                 else
    10.                     return new Vector2(otTransform.position.x - offset.x, (OT.world == OT.World.WorldTopDown2D)?otTransform.position.z - offset.y:otTransform.position.y + offset.y);
    11.             }
    12.             else
    13.                 return Vector2.zero;
    14.         }
    15.         set
    16.         {
    17.            
    18.             if (otTransform == null)
    19.                 otTransform = transform;
    20.  
    21.             Vector2 pos = value;
    22.             if (worldBounds.width != 0)
    23.             {
    24.                 float minX = _worldBounds.xMin;
    25.                 float maxX = _worldBounds.xMax;
    26.                 float minY = _worldBounds.yMin;
    27.                 float maxY = _worldBounds.yMax;
    28.                 pos.x = Mathf.Clamp(pos.x, minX, maxX);
    29.                 pos.y = Mathf.Clamp(pos.y, minY, maxY);
    30.             }                  
    31.                        
    32.             if (OT.world == OT.World.WorldTopDown2D)
    33.                 otTransform.localPosition = new Vector3(pos.x + offset.x, paintingDepth, pos.y - offset.y);
    34.             else
    35.                 otTransform.localPosition = new Vector3(pos.x + offset.x, pos.y - offset.y, paintingDepth);
    36.                                    
    37.             _position = pos;
    38.             _position_ = pos;
    39.             Changed();
    40.            
    41.         }
    42.     }
    The problem is inside the getter function:

    Code (csharp):
    1. return new Vector2(otTransform.localPosition.x - offset.x, (OT.world == OT.World.WorldTopDown2D)?otTransform.localPosition.z >>> - <<< offset.y:otTransform.localPosition.y + offset.y);
    2.  
    There you can see the marked "-",,,maybe this is an old code from long ago, but this minus must be a plus because of the setter below.
    This solution fixed all my re positioning problems.
     
  2. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    Thanks for the catch .. I will review it and check it into the core if it checks out right...
     
  3. iconsam

    iconsam

    Joined:
    Jul 24, 2013
    Posts:
    2
    This question might have been answered already, but had a hard time finding it on the main site.

    How would you go about setting a custom font for the Ortherllo GUI button prefab? I was able to set it on the scene, and works initially, but when another scene is loaded and the original scene comes back into view, the original Orthello fonts are used once again and my changes are gone.

    Great framework!
     
  4. ishaq

    ishaq

    Joined:
    Nov 12, 2008
    Posts:
    33
    I want to load an animating sprite from a texture atlas at run time, I have this code (which gives me a frameset with startFrame = 0 and endFrame = -1, and displays only the first frame on screen).



    Code (csharp):
    1.  
    2.  private OTAnimatingSprite LoadAnimatingSprite(string textureFile,
    3.         string atlasFile, Vector2 position)
    4.     {
    5.         OTSpriteAtlasCocos2D atlas =
    6.             OT.CreateObject("AtlasCocos2D").GetComponent<OTSpriteAtlasCocos2D>();
    7.         atlas.texture = OTHelper.ResourceTexture(textureFile);
    8.         atlas.atlasDataFile = Resources.Load(atlasFile) as TextAsset;
    9.         atlas.reloadData = true;
    10.  
    11.         OTAnimation animation =
    12.             OT.CreateObject(OTObjectType.Animation).GetComponent<OTAnimation>();
    13.         OTAnimationFrameset frameset = new OTAnimationFrameset();
    14.         frameset.container = atlas;
    15.         frameset.startFrame = 0;
    16.         frameset.endFrame = (atlas.frameCount - 1);
    17.         animation.framesets = new OTAnimationFrameset[] {frameset};
    18.  
    19.         OTAnimatingSprite animatingSprite =
    20.           OT.CreateObject(OTObjectType.AnimatingSprite).GetComponent<OTAnimatingSprite>();
    21.         animatingSprite.animation = animation;
    22.         animatingSprite.playOnStart = true;
    23.         animatingSprite.looping = true;
    24.         animatingSprite.position = position;
    25.         animatingSprite.name = "AnimatingSpriteThroughCode";
    26.         return animatingSprite;
    27.     }
    28.  
    any help would be appreciated.
     
    Last edited: Oct 27, 2013
  5. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    Normaly it takes an update cycle or 2 to initialize an atlas so maybe create your atlas in the start, and your animation and sprites , after the first update cycle.

    using for example ...

    Code (csharp):
    1. OT.Execute(0.1f, delegate() {
    2.    SetupMySprites();
    3. });
     
  6. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    A Orthello form elements button uses a OTTextSprite for the caption, that uses a font atlas to determine what font is used. Best approach will be to setup your font atlas first, than your textsprite and put that into your button.

    After setting up your own custom button, you could put that into a prefab and use that as your button base object. Just make sure that in a new scene your font-fatlas is also present.
     
  7. Friend123

    Friend123

    Joined:
    Sep 16, 2012
    Posts:
    19
    Need help. I have a similar problem.
    Orthello 2D version: 2.8. Frame index of OTAnimatingSprite is reset when i press CTRL+S or reopen scene.
     
  8. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    If you have a similar problem it should be fixed when you use normal OTSprites for static 'one frame' sprites,
    and animation sequences for OTAnimating sprites. Also setup your sprites in the scene en not the prefabs
    in the project window.

    Also .. compare your sprites and code with the examples that contain animations, like
    example 3 - Asteroids and example 5, creating at runtime. If you set it up the same way all should be fine...
     
  9. m_eilers

    m_eilers

    Joined:
    Jul 3, 2013
    Posts:
    13
    Hello... thanks to help on this thread, my 2D drag is working perfectly! Once I clean up the code I will share it here. However, I have another issue... I am using OTTween to "snap" tiles home so that they always align with the grid. This works PERFECTLY in the Unity editor in both PC/Mac build and iOS build modes. It also works in the iPad emulator via Xcode. The app also builds with zero errors (two minor warnings, both about deprecated calls that are Unity's problem).

    However, when I actually run the code on my iPad 2, the OTTween is totally ignored and does not happen. I am seeing no exceptions when running in Xcode, so I have no idea what is going on. Here is my code for the tween:

    Code (csharp):
    1.     new OTTween(OT.AnimatingSprite(snapName),.15f,OTEasing.StrongInOut).
    2.                     TweenAdd("position",new Vector2(amountToSnap,0),OTEasing.StrongInOut);
    Any idea why this would work on Mac/PC in Unity but not work on an iPad?

    BTW snapName is just a string for the Object I am tweening, everything else looks exactly like it does in the code examples for OTTween.
     
    Last edited: Oct 31, 2013
  10. Friend123

    Friend123

    Joined:
    Sep 16, 2012
    Posts:
    19
    Thank's. My goal was to animate buttons. I've done one animation for all frames and appeared this problem. And when i've done animations for every button - all was good.
     
  11. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    I really cant say .. maybe something to do with some strange ipad2 initialisation (order) .. maybe first make sure the the OTAnimatingSprite is up and running and pass that instead of a lookup?
     
  12. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    I checked the code and you are very right .. probably because the Top2D view is not used that much the bug never surfaced before. I implemented your solution and it will be rolled out in the next update ...

    Thanks for improving Orthello!
     
  13. m_eilers

    m_eilers

    Joined:
    Jul 3, 2013
    Posts:
    13
    I can't tell; it may be Xcode using an older build of the code, Xcode is really infuriating to work with...

    Is there a guide as to what to initialize and when? It seems the code examples use different approaches. I am instantiating my animating sprites via a loop, and they can be touched/clicked and animated at this point, so i would think they are fully initialized. Does OTTween need an init? Because I am generating my sprites at runtime, I don't know the name of the sprite, so that is why I have to do the lookup.
     
  14. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    Most safest way is to instantiate/create all sprites and objects in the void Start()
    and start to work with them in the Update();

    so OTTween's after the first update cycle (maybe wait some cycles to be on the safe side) but I normaly experience no troubles with my tweens.

    To solve your iPad problems .. try and write debug some info to the screen using GUI to see why trhe tween is not working.. you might even need to add some temporary debug functionality to the tween to finish your quest .. can be difficult...
     
    Last edited: Nov 4, 2013
  15. fafet

    fafet

    Joined:
    Sep 2, 2013
    Posts:
    7
    Hi, i'm new to Othello and a suffer from a mind freeze. I can't figure out to control my animated sprite by code. Stanges behaviors. If i debug log something very simple like Time.fixedTime to the console a get nothing if a put it in the update function i have in the script attached to my animating sprite. I initialized call backs but still don't work at simply acitvating/activating sprites. Could you help me?

    here is the code:
    Code (csharp):
    1. var preliminaires : OTObject;
    2. var x :float;
    3. var y :float;
    4. private var speed:Vector2 = new Vector2(150, 150);
    5.  
    6.  function start () {
    7. preliminaires = OT.ObjectByName("preliminaires") as OTAnimatingSprite;
    8. preliminaires.InitCallBacks(this);
    9.  }
    10.  
    11. function IsActive(preliminaires : OTObject) {
    12. if (Time.fixedTime> 2){
    13. preliminaires.Activate();
    14. Debug.Log(Time.fixedTime);
    15. }
    16. else{
    17. preliminaires.Deactivate();
    18.  
    19. }
    and an image of my scene:

    $Capture.JPG
     
  16. fafet

    fafet

    Joined:
    Sep 2, 2013
    Posts:
    7
    I answer myself: solved the problem by moving my script in a deeper path in my projec folder. Just that! Thanks for this brillant Orthello that does for the video game what Shakespeare did to litterature with his Othello!
     
    Last edited: Nov 5, 2013
  17. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    Happy to hear that you have solved it! and ... tx!
     
  18. terragoetia

    terragoetia

    Joined:
    Oct 2, 2013
    Posts:
    1
    Hi, I'm having a problem with an Animating Sprite and a Character Controller.
    $AnimError1.PNG
    Here's an Animating Sprite I'm using in a game as a place-holder. He works just fine--he can walk on tiles (which are rigidbodies), and do his animations. He's also very simple in his animation. Then we switched to a more modern-looking animation:
    $AnimError2.PNG
    The main difference is that--in this animation--the character is slightly taller when he stands still, and slightly lower when he runs. The issue is that now he can run through walls. He will also fall through one layer of floor tiles if he stops from a run (but not if just standing still).

    I've been adjusting his Controller, but to no avail; the problem goes away immediately if I revert him to his old animation. I don't want to have to ask my artist to do any more work than needed; is there something I can do to fix it so the new animation doesn't go tumbling through things?
     
  19. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    An animation is a series of sprites/frames that are taken out of an atlas. Most of the time, the atlas is optimized and trims/crops empty space around your frame's images to conserve memory. Orthello supports this kind of atlas and uses the atlas frame offset data to make sure that the sprites-frames are positioned on the right spot during an animation.

    A downfall of this is that the position of your sprite mesh is not always the same and because the sprite has its own collider attached, that will move as well. When your characters collider moves across the border of your wall of floor collider, it has passed and will fall/move through.

    so ...

    A way to get around this is to remove the collider of your character animating sprite and add some other static object/sprite just for colliding purposes and let that be your moving object. Then match your character display with that movment/colliding object (maybe put your character sprite as a child of that moving parent). You can disable the mesh renderer of the moving parent.

    This way your character sprite is just for the display and your collider object is used for collisions.

    Hopes this makes sense....
     
    Last edited: Nov 8, 2013
  20. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    Unity 4.3 has been released ....

    I expect a Orthello 3.0 Beta version with SpriteRenderer (OTUnitySprite) support in a week or two ...
    ( Box2D physics support will also be in there ... )
     
  21. t3d-planet

    t3d-planet

    Joined:
    Apr 26, 2013
    Posts:
    11
    anybody knows if the internal tweening system can ignore timescale ?
     
  22. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    It can not, because it is related to the Monobehaviour.Update that is timescale dependend.

    What are you trying to achieve?
     
  23. t3d-planet

    t3d-planet

    Joined:
    Apr 26, 2013
    Posts:
    11
    well,i am trying to pause the whole scene using timescale=0 except one moving spirit using tween class!!!! so i guess its not achievable ,anyway i can use itween system because last i checked there was an " ignore timescale" boolean.
     
  24. ADT

    ADT

    Joined:
    Oct 7, 2013
    Posts:
    6
    Hey guys, I've been using Orthello Pro for about a year now, and with the release of the the Unity 2D toolset, can anyone give me a break down of the pros and cons between this and that? I've looked at the new toolkit and I honestly have no idea if it would be worth it moving my current project into the new Unity 2D Toolkit.

    Like is Orthello more powerful? Does it run better? Have more features? I'm just really confused, but I truly love Orthello and what I've be able to do with it, but the new system looks awesome at the same time.

    Thanks for any help.
     
  25. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    I am in the process of releasing the BETA of Orthello 3.0 with SpriteRenderer support. After that I can probably give you a better headsup but for now .. here it goes :

    Unity2D ==

    - auto slice images from an atlas (or single image) to a spritemesh ( polygon ).
    - sprites integrate very beautiful with Unity animation system
    - introduces Box2D physics in additon to regular Physx ( but only works on 1 unity unit == 1 meter scene dimensions )
    - texture packing ( spritebatching? ) in Unity Pro

    Why Orthello 3.0 will be an asset

    - leverages SpriteRenderer (Unity2d) sprites using new OTUnitySprite, so you get the Unity2D sprite but with Orthello functionality like : drag and drop, tweening, sprite.clicked, sprite.mouseHover, OT.Sprite(...) lookups etc etc...

    - Still has many other sprite types that are custom controlled meshes that can not be done i Unity2D (only image slicing) .. like gradient sprite, grid sprite, filled sprite, circular (progress) sprite etc etc

    - Box2D in Orthello by setting sprite.box2D = true, but as stated above only works with custom view sizes because 1 unit = 1 meter instead of Orthello default 1 unit = 1 pixel .. hopefully this will be solved in a future update .. have made a request to be able to scale gravity vectors ...

    - Orthello is not just sprites .. it is a framework, making your life as an 2D developer a bit more relaxing .. sound support, OT.execute, tweening , tilemap + parallax components in PRO etc etc.

    Thats about it ..

    so .. the question is not if you will cross over but what sprites you will be going to impement in Unity2D. It integrates very nicely with Orthello.

    Hope this answers your questions....
     
    Last edited: Nov 17, 2013
  26. ADT

    ADT

    Joined:
    Oct 7, 2013
    Posts:
    6

    Thanks so much for the response. I was attempting to play around with the Unity 2D toolkit and it was simplistic, and not as robust as Orthello. Your post was exactly what I was looking for and will be sticking with Orthello, just because of the the amount of things I can easily implement with it.

    Thanks again for the reply, and thank you for making a wonderful framework. :D
     
  27. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    Thanks .. and 2 more ...

    - Texturepacking, that is a Unity 2D Pro fature only .. creates a very nice mesh based atlas for you but you have almost no control over it. In Orthello, all versions , TexturePacker atlas import is out of the box .. using TexturePacker you have total control over the atlases that you would like to use.

    - Orthello comes with multi resolution support (using resource directories) out of the box .. where Unity2D has none I believe...
     
  28. raulunity

    raulunity

    Joined:
    Nov 20, 2013
    Posts:
    1
    Hi, is there any way to know the real size of a OTTextSprite, not the scale. Thanks!
     
  29. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    try using sprite.worldRect

    but only after your textsprite is set correctly, for after changing text, it takes 1 update cycle to reflect that change .. you can force that by calling sprite.ForceUpdate()
     
  30. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    Orthello 3.0 beta

    .... with OTUnitySprite == Unity2D sprite support

    download here , test and give your feedback.

    note that :

    - the OTUnitySprite will only work in Unity 4.3
    - regular orthello sprites/objects will be at default 2D sorting layer (id==0) , with sorting order 0
    - sprite.box2DPhysics = true to select box2d physics for that sprite ( UnitySprites can also use Physx instead of Box2d )
    - Box2D will only simulate correctly on systems where 1 unit == 1 meter, so use a OT.view.customSize
    - sprites can only interact with sprites that use the same physics system.

    - Create a UnitySprite by :
    1. dragging a UnitySprite object/prefab into your scene
    2. link the Unity 2d sprite to the attached sprite renderer.
    3. thats it .. all regular Orthello functionality like click, drag and drop etc should work

    P.s. Contact me if you use an Orthello Pro version and would like the 3.0 Pro beta.

    Blog post : Unity 2D sprites and why Orthello is still an asset.
     
    Last edited: Nov 21, 2013
  31. ihazbackup

    ihazbackup

    Joined:
    May 23, 2013
    Posts:
    8
    Hi, I'm using orthello pro and I'm stuck in this collider problems.

    Before I was using orthello pro with version lower than 2.9. The collider generations worked fine.
    Then I use the version 2.9 because of the support for windows phone. Now tilemaps won't generate colliders (no child named 'collider' in tilemap). I'm still using the same XML layout and tilesheet.

    is there any problem with the XDocument and XmlDocument in tilemap?

    any help is appreciated . THX
     
  32. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    probably a bug cause by the XML handling change .. can you please create a package with an example that demonstrates the problem and instructions on how to reproduce this error to info at wyrmtale dot com ..

    lets squash this bug!

    UPDATE
    Seems that there is indeed a bug in the OTTilemap - XMLDatareader combination ( for all platforms ) that touches the collider generation. We are testing the fix at this time and will put this fix into the upcoming 3.0 version.
     
    Last edited: Dec 5, 2013
  33. dozus

    dozus

    Joined:
    Dec 7, 2013
    Posts:
    1
    Hello there,

    I am ihazbackup colleague, the solution given was fixing the unity collider issues. But when it's build to the Windows Phone 8, the collider is considered as null (doesn't show up).

    Any idea what's going on?

    below some snippet

    tileMap = GetComponent<OTTileMap>();
    // this file has OTTileMap Component
    ---------------v------------- tiles always null in WP8, no problem in editor
    Transform tiles = this.transform.FindChild("colliders");
    for (int i = 0 ; i < tiles.childCount ; i++){
    Transform tileGroup = tiles.GetChild(i);
    for (int j = 0; j < tileGroup.childCount ; j++){
    if (tileGroup.GetChild(j).gameObject.name == "tilemapCollider"){
    tileGroup.GetChild(j).gameObject.tag = "collider";
    tileGroup.GetChild(j).gameObject.layer = 8;
    } else {
    tileGroup.GetChild(j).gameObject.tag = "walkable";
    tileGroup.GetChild(j).gameObject.layer = 9;
    }
    }
    }
    }
     
  34. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    No, I have no clue at this time .. I will investigate it further.
     
  35. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    Update

    I have tested the tilemap example that is provided with the Orthello framework as a win8 Metro app (local) and that
    has the colliders. Testing on a win8 phone is not possible for me at this time .. so best thing for you would be
    to find the code where the colliders are created and trace what is going on in the code there...
     
  36. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    Orthello 3.0 released.

    - Unity2D SpriteRenderer support
    - Unity2D Box2D physics support
    - Mesh (Polygon2D) collider through sprite.colliderType == Shape

    Download it here
     
    Last edited: Dec 9, 2013
  37. valerik

    valerik

    Joined:
    Aug 8, 2013
    Posts:
    11
    Hi, I'm new in using Orthello, so be patient with me if i'm doing something wrong =)

    My goal is to create a board game based on 40x32 tiles. Behind the 1280 tiles there will be a panel that represent my battlefield and only the tiles that represents the units are enabled and rendered. The other are disabled and transparent.

    I'm switching to Orthello because theoretically I can batch all tile sprites ( 40 units more other 10 texture for a total of 50 different sprites of 256x256px) and have only 1 draw call (2 if they don't fit a single sprite sheet).

    Here start the troubles.
    I have:
    OT
    |->Containers
    |-> testSpriteSheet (is an OTSpriteSheet)

    BatchSprite (its an OTSpriteBatch object renamed)
    |-> TileFrame (it's the OTSprite object renamed that I'm using to test, I create them dinamically at runtime)
    |-> TileFrame1
    |-> TileFrame 2
    etc etc

    first problem: frameXY and frames sizes of sprite sheet are correctly set, but I can actually change the frame index of an OTSprite at runtime. In the editor it works.

    Second problem: I assign a transform position at each TileFrame(OTSprite) but they don't change position, I try to change position before assign SpriteBatch as parent and either after but in both situation position is always 0,0,0.
    I see that the only way it's to set the position in the editor without generate tiles...but i can't do this for all 1280 tiles! Also using an other way, without create 1280 tiles but only moving existing sprite in the new position this could be a problem by the fact OTSprite don't change position.

    third problem: here (http://www.wyrmtale.com/orthello-pro/sprite-batching) I read about spritebatchMonitor and autoCheckSprites method to update sprites inside batch, but these option doesn't exist, neither in the editor inspector, neither in the code of OTSpriteBatch.
    Again, as like for OTSprite without batch, changing the frame index nothing happens, I need to check and uncheck "Pack Texture" option to update (probably because it calls Build() method) the new position that I set at runtime by inspector.

    What I'm doing wrong?
    Thanks in advance for your help =)

    EDIT: I forget to say I'm using orthello pro 2.9v
     
    Last edited: Dec 9, 2013
  38. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    Could be that the documentation is not up to date ( will check into that ) because batched sprites always call a 'changed handler' to inform the batch they are changed and need to be updated. So those monitoring settings where removed.

    Your problems could be caused by the fact that your sprites are not initialized correctly when created runtime.
    Could be that you are creating the sprites at runtime the wrong way .. are you using the 'Orthello' way so .. using OT.CreateSprite ?

    anyway ....

    In your case you will be better off using the (PRO) OTTilesSprite. This sprite was especially made to create 1 big tiles based sprite (usually 1 drawcall)
    check into the example @ Pro 6 - TILED - Tilemap Support. CProExample-TilesSprite
     
  39. valerik

    valerik

    Joined:
    Aug 8, 2013
    Posts:
    11
    Yeah, it works, 1280 tiles in 1 draw call =) Thanks very much!
     
  40. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    I am very happy that it worked for you!
    Keep it up..
     
  41. ekkiiiii

    ekkiiiii

    Joined:
    Apr 2, 2013
    Posts:
    3
    Hello again!
    First let me thank you for your answer on my last question a while back, even though the error was totally on my side your answer helped me be sure that I got everything else right.

    Today I want to adress the tilemap-depth issue again (it has already been adressed here, and you asked for an example here, though I guess you did not receive it, since I could not find anything regarding this issue afterwards?

    I have a character that moves on a tilemap, and by changing its depth it is possible to have him drawn in front of or behind the tilemap. But having different layers with different depths does not work.

    In my example I have a tree and, while moving, the character should be drawn behind the upper part of the tree, while he should be drawn in front of the lower part. I created my TILED-tilemap accordingly, with a layer for each part of the tree with different depth properties.
    Those generally get overridden by orthello and changed to a decrementing order (layer 1: depth -1, layer 2: depth -2, ...), which I tried to fix by changing the depth at runtime. That seems to work in theory, meaning the layers depth-property can be changed to -100 or something, but the AnimatingSprite still gets drawn in front of it, even though the tile-layers depth is way below the characters depth.
    In Unitys 3D view the tilemaplayers and the animating sprite all appear to be in the right position, but during runtime they don't get drawn the way i expect them to...

    Thank you for great support here and keep up the good work!
     
  42. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    To be able to discriminate the ordering between tilemap layers and regular (animating) sprites, you need to load any discriminating tilemap layer as a seperate tilemap (thus a tilemap sprite).

    Only sprite meshes can be ordered seperately and a tilemap is one big sprite mesh. The ordering within will work but combining it with seperate meshes will only work mesh based.

    Hope this answers your question..
     
  43. Heatith

    Heatith

    Joined:
    Jun 2, 2013
    Posts:
    11
    Hey, lucky I thought about checking this topic, otherwise I wouldn't have seen your post ekiiii. Well, I actually did give mas an example and he was able to give me a few lines of code to change the tilemap generation according to the layers' different depths.

    The problem is that it still gets drawn as one single mesh. So a sprite can't fully "interact" with it if you change its depth for it to appear behind the upper part of a tree. As mas wrote, you'd have to generate a mesh per layer, thus using the tilemap class for eeach of your layers (saved as different files).

    But personally I'll try and change the code so that it generate one mesh per layer instead of having three files and three different tilemap sprites used. Now that I have a proper connection again, I can get back to work.
     
  44. ekkiiiii

    ekkiiiii

    Joined:
    Apr 2, 2013
    Posts:
    3
    Thank you for the clarification mas, I understood why it doesn't work now. Since the desired effect is not that important and I do want to avoid confusion in the map creation process I will just leave "walking behind tiles" out for now.

    Also, thank you Heatith for your answer, please let me know if you get the layered meshes for tilemaps working somehow, that really seems like the most elegant way to solve the issue!
     
  45. ishaq

    ishaq

    Joined:
    Nov 12, 2008
    Posts:
    33
    I am working on an animation heavy 2D project. So far my experience with setting animations up in the editor with orthello2D has been great. but doing through code (loading sprite atlas, texture, configuring animation and creating an animated sprite) hasn't been that easy. I have been able to manage it though.

    the question is, I have many animations (100+ frames each) that may or may not be needed when playing the game. so I load them only when needed and destroy them after playing. is this the correct approach? or is there a better way to do it? (I have Orthello2D Pro).
     
    Last edited: Dec 19, 2013
  46. ishaq

    ishaq

    Joined:
    Nov 12, 2008
    Posts:
    33
    how do I destroy an OTAnimation object?
     
    Last edited: Dec 19, 2013
  47. ishaq

    ishaq

    Joined:
    Nov 12, 2008
    Posts:
    33
    here's how I load an animating sprite at runtime (pseudo code)

    - load atlas, assign it a texture
    - wait for a couple of cycles to make sure atlas gets populated
    - create an animation, it has one single frameset that has all the frames in the atlas
    - create an animating sprite and assign it the animation in the step above


    this works fine the first time, when I destroy the animating sprite and do the exact same steps again, animating sprite's size is set to 100x100 pixels (instead of the correct size).

    any ideas?

    NOTE: I cannot setup my animations in the editor because I have a large set of animations which only get played when needed, so I need to do this at run time to save RAM.
     
    Last edited: Dec 19, 2013
  48. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    OT.DestroyAnimation(OTAnimation animation);
     
  49. mas

    mas

    Joined:
    Nov 14, 2010
    Posts:
    696
    That the sprite is 100x100 the 2nd time , sounds like an (re?-)initialization bug because 100x100 is a sprite default. Is your sprite send back to the object pool (when using OT.DestroyObject) or do you use Destroy(sprite.gameObject) ?
     
  50. ishaq

    ishaq

    Joined:
    Nov 12, 2008
    Posts:
    33
    I use OT.DestroyObject, no idea what's happening.