2D Toolkit Forum
2D Toolkit => Support => Topic started by: arvz on May 31, 2014, 05:12:12 pm
-
I'm using tk2dStaticSpriteBatcher to batch a bunch of 'block' object into a collection of block objects. It looks like this:
(http://i.imgur.com/A7vjygr.png)
As you can see, this batched sprite is comprised of many edge colliders.
Due to the way some other parts of my game works I need the object to have just 1 edge collider surrounding just the 'actual' edges of the object, like this:
(http://i.imgur.com/BBPQf3h.png)
I made that collider myself, as you can see it's pretty rough and takes a long time to edit manually by shift-clicking the collider vertices into place.
I realise tk2d doesn't really have any feature to do this, but I was wondering if you might be able to suggest some options I could try?
Thanks!
-
The tk2d tilemap editor will perform this optimization, its worth a try to see if it'll do what you need.
-
I need to position/instantiate these dynamically on runtime though so I don't think the tilemap editor will work for me in this case
edit: Just tested it, and the optimization does work. I still need to use the object in a non-tilemap manner though. Maybe I can just copy the edge collider it generates and just paste it into my object? This is still a lot of work as I'd have to make the objects twice (Once in the tilemap, and another just by placing them manually and batching them) Is there a better way?
-
Well you do have the code, you could simply get the code that optimizes the tilemap collider and apply it to the static sprite batcher collider - it'll be a bit of work, but if you need the functionality it will be the best way to go about it.
The relevant functions are tk2dStaticSpriteBatcher.BuildPhysicsMesh2D
and tk2dTileMapColliderBuilder2D BuildForChunk - the code there is fairly well documented.