Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - limegreen

Pages: [1]
1
Support / Custom renderer for tiles
« on: September 21, 2017, 04:22:31 pm »
Hi,

Let me first describe what I am trying to do, in case I'm just barking up the wrong tree.  I am working on an isometric game, and have thus far created a tilemap with two layers - one containing ground tiles (so far just the same grass tile) and one containing things like trees and bushes.  It occurs to me that this may already be wrong - perhaps I should be placing that landscape "furniture" as independent sprites instead of as tilemap elements?

Anyway, I now have the problem that any isometric game has - how to handle occlusion of animated characters as they move around things like trees.  I googled around looking for solutions, but the most common one - splitting sprites into a top half and a bottom half, and then making sure that animated characters can't walk paths that would spoil this illusion - seems unsatisfactory, and it would require me to start messing about with paint programs, and that would just end in tears...   :)   Eventually, I found a Unity package that implements a shader-based sprite renderer that supports per-pixel draw order, amongst some other nice stuff like 3D-style lighting.  This is the product: https://forum.unity.com/threads/shiva-2-5d-isometric-engine.486274/

So, I *think* all I need to do is change my tk2d sprites to use this renderer instead of the standard SpriteRenderer, but I can't find a place to do that in SpriteCollection.  Do you think I will be able to integrate this thing with tk2d?

Thanks!

2
Support / Can't get world ray to identify tile
« on: September 16, 2017, 10:28:36 pm »
I am using a Tilemap and right now I have no real use for colliders so I want to avoid them.  However, I do need to respond to mouse clicks on the map.  I came across this post: http://2dtoolkit.com/forum/index.php/topic,2304.msg11501.html

In there is this advice:

Quote
Don't use colliders. Get the intersection of the cursor / touch ray and tilemap plane
      Plane p = new Plane(tileMap.transform.forward, tileMap.transform.position);
      Ray r = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
float hitD = 0;
if (p.Raycast(r, out hidD)) {
  Vector3 hitPoint = r.GetPoint(hitD);
}

When I try to do this, I get this error:

Unable to convert GUI point to world ray if a camera has not been set up!

I have tried this with a tk2dCamera in the scene, a regular Unity Camera in the scene, and with both, and I always get this error.  Any suggestions?

Thanks,
Wayne

3
Support / Can't select Sprite animation
« on: September 12, 2017, 08:09:05 pm »
I am using 2D Toolkit 2.5.6 with Unity 2017.1.1f1.  I am completely new to tk2d, and no great shakes with Unity either, so I may well have done something stupid. 

I have imported a sprite sheet image into a tk2d Sprite Collection, and I can see that it has isolated the individual sprites correctly into their own images.

I have created a Sprite Animation that refers to this collection.  I asked tk2d to fill the clip with the "Autofill 1.9" button, which it did correctly.  I can click the "Play" button and see my sprite animating as I expect in the Sprite Animation editor.

So now I add a sprite with GameObject -> Create Other -> tk2d -> Sprite with Animator.  That lets me select my Sprite Collection, and it then auto-selects the first image as "Sprite", and that image is displayed underneath, exactly as expected.  However, when I try to change the "Anim Lib" in the "Tk 2d Sprite Animator" section, I see my SpriteAnimation in the drop down box, but when I try to select it, it just silently reverts to the default (first) one.  At the same time, I get this error logged in the console:

NullReferenceException: Object reference not set to an instance of an object
tk2dSpriteAnimatorEditor.OnInspectorGUI() (at Assets/TK2DROOT/tk2d/Editor/Sprites/tk2dSpriteAnimatorEditor.cs:91)

The line of code in question is this:

        if (animator.Library.clips.Length > 0)

Can you help me to understand what the problem is, or how I can find out more about what's going on?

Pages: [1]