16
Support / Re: Animated tiles and a suggestion
« on: June 21, 2016, 05:33:55 am »
Thanks for the reply!
Regarding the line of code you commented about - prior to that loop I set the uv's to the custom coordinates with this:
coll.spriteDefinitions.uvs = gen.textureParams.CustomUV;
I do not use the atlas' uv coordinates. In hindsight I should have applied the offset to CustomUV first before setting it to spriteDefinitions.uvs to eliminate confusion.
I have a bool to turn it on or off called UseCustomUV. I sometimes have an animation that is larger than a single tile, where a series of tiles represent that animation. The offset makes this easier and faster to enter coordinates for these larger animations. These larger animations are also why I allow entry for all four UV coordinates. Well, that or if the user wants to do something funky.
I am handling things similar to you - the Tile in the Tileset is merely a placeholder for the animated material. The original UV rect does not apply to me in these animations, so I use the custom uv values to properly handle my animations.
How do you handle these situations without plugging in UV values? Do you adjust the material scale and offset? I was unable to acquire 1:1 accuracy with this method; the animations were always a little too big or a little too small. I was also unable to reuse an animation with another Sprite Collection without creating a new material. With the scope of my game in mind that would have caused me to create hundreds of extra materials. It also didn't seem compatible with larger animations without creating more materials. Custom UV's allowed me to use just one material per animation no matter how large the animation and across all Sprite Collections. I imagine this would also result in fewer draw calls. I need them to be 1:1 with the rest of the tiles.
My requirements are this:
1:1
Support for larger animations where the tile represents only a piece of it.
Keep the material count limited
What do you recommend?
Regarding the line of code you commented about - prior to that loop I set the uv's to the custom coordinates with this:
coll.spriteDefinitions.uvs = gen.textureParams.CustomUV;
I do not use the atlas' uv coordinates. In hindsight I should have applied the offset to CustomUV first before setting it to spriteDefinitions.uvs to eliminate confusion.
I have a bool to turn it on or off called UseCustomUV. I sometimes have an animation that is larger than a single tile, where a series of tiles represent that animation. The offset makes this easier and faster to enter coordinates for these larger animations. These larger animations are also why I allow entry for all four UV coordinates. Well, that or if the user wants to do something funky.
I am handling things similar to you - the Tile in the Tileset is merely a placeholder for the animated material. The original UV rect does not apply to me in these animations, so I use the custom uv values to properly handle my animations.
How do you handle these situations without plugging in UV values? Do you adjust the material scale and offset? I was unable to acquire 1:1 accuracy with this method; the animations were always a little too big or a little too small. I was also unable to reuse an animation with another Sprite Collection without creating a new material. With the scope of my game in mind that would have caused me to create hundreds of extra materials. It also didn't seem compatible with larger animations without creating more materials. Custom UV's allowed me to use just one material per animation no matter how large the animation and across all Sprite Collections. I imagine this would also result in fewer draw calls. I need them to be 1:1 with the rest of the tiles.
My requirements are this:
1:1
Support for larger animations where the tile represents only a piece of it.
Keep the material count limited
What do you recommend?