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.


Messages - Biktor

Pages: [1]
1
Support / Re: Animated tiles
« on: March 12, 2015, 04:26:26 pm »
Great, you are right  :)
Padding between each tile-frame is the solution.

2dToolkit is an awesome tool.
One more time, thank you very much.

2
Support / Re: Animated tiles
« on: March 11, 2015, 12:01:01 pm »
Sorry to resurrect this topic, but being a related question I think is the best place.

I'm using material overrides in the sprite collection for my tilemap.
The material is animated with this shader:

Code: [Select]
Shader "Custom/2DToolkit_AnimatedTexture"
{
Properties
    { 
    _MainTex ("Base (RGB)", 2D) = "white" {}
   
        // Create the inspector values
        _FrameWidth ("Frame Width", Float) = 0.0
        _TotalFrames ("Total Frames", Float) = 0.0
        _FPS ("FPS", Float) = 0.0
    }

    SubShader
    {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100

ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha

Pass

CGPROGRAM
#pragma vertex vert
#pragma fragment frag

#include "UnityCG.cginc"

struct v2f
{
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
};

sampler2D _MainTex;
float4 _MainTex_ST;
         
        //Create the connection to the properties inside of the   
        //CG program
        float _FrameWidth;
        float _TotalFrames; 
        float _FPS;
       
        float _Tick;

v2f vert (appdata_base v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
//o.texcoord = mul(_Object2World, v.vertex).xy * _MainTex_ST.xy + _MainTex_ST.zw;
return o;
}

fixed4 frag (v2f i) : COLOR
{
//ANIMATION 
            float2 spriteUV = i.texcoord;
            _Tick = frac(_Time.y * _FPS);
            spriteUV.x = spriteUV.x + ( floor( _Tick * _TotalFrames ) * _FrameWidth );

fixed4 col = tex2D(_MainTex, spriteUV);
return col;
}
ENDCG
}
}
}

Here is the test texture for the material:



And here the shader inspector:



The performance is great and the animations works perfectly with all sprites except with the water tiles.
The tile is not drawn correctly and consequently the animation has an ugly result.




Where is the problem?
I've been playing with the sprite collection settings with no success and I'm lost.

Thank you.

3
Support / Re: Animated tiles
« on: November 06, 2014, 05:53:23 pm »
Great, now works  :)

Thank you very much.

4
Support / Re: Animated tiles
« on: November 05, 2014, 09:30:26 am »
I'm lost...  :-\

I'm trying to fix it with _Object2World, but... I haven't been successful.

Could anyone give me some clue about the way to fix it?

5
Support / Re: Animated tiles
« on: October 31, 2014, 01:11:32 pm »
Ok, I will try to explain my best ( please, excuse my english)

I use a "filmstrip texture":


So step by step:
  • I am usign your Tile Map tutorial
  • A new material is created, with my custom shader and with the filmstrip like the texture...
  • ... and use " Multiple Materials" on the tile sprite collection ( first screenshot)



If I use my shader in a quad, all works perfectly ( second screenshot):



But in the tilemap, the tile with the " multiple material" doesn't work ( is animated, but " over sized"?)



I'm playing with the tilling and offset values, but I haven't got to fix it.



6
Support / Re: Animated tiles
« on: October 30, 2014, 09:35:06 am »
Ok, here is my shader:

Code: [Select]
Shader "Custom/2DAnimatedTile"
{
Properties
    { 
    _MainTex ("Base (RGB)", 2D) = "white" {}
   
        // Create the inspector values
        _TotalFrames ("Total FRames", Float) = 0.0
        _FPS ("FPS", Float) = 0.0
    }

    SubShader
    {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100

ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha

Pass

CGPROGRAM
#pragma vertex vert
#pragma fragment frag

#include "UnityCG.cginc"

struct v2f
{
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
};

sampler2D _MainTex;
float4 _MainTex_ST;
         
        //Create the connection to the properties inside of the   
        //CG program 
        float _TotalFrames; 
        float _FPS;
       
        float _Tick;

v2f vert (appdata_base v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}

fixed4 frag (v2f i) : COLOR
{
//ANIMATION
                        //Lets calculate the width of a single cell in our 
                       //sprite sheet and get a uv percentage that each cel takes up. 
                       float frameUVPercentage = 1.0/_TotalFrames;
                       //Lets store our UVs in a variable 
                       float2 spriteUV = i.texcoord;
                       _Tick = frac(( _Time.y + frameUVPercentage ) * _FPS) - frameUVPercentage;
                       spriteUV.x = ( spriteUV.x + frameUVPercentage ) + ( floor( _Tick * _TotalFrames ) * frameUVPercentage );

fixed4 col = tex2D(_MainTex, spriteUV);
return col;
}
ENDCG
}
}
}

Works perfectly with sprites, but... if I make a TileMap and use " Multiple Materials" on the tile sprite collection, the material is animated but is over sized and I have no idea where is the problem.

What am I doing wrong?
Some idea or clue?

7
Support / Re: Animated tiles
« on: October 20, 2014, 09:04:34 am »
First of all, thank you for the quick answer.

This weekend I have read some tutorials about this.
My game is targeted to mobiles and tables, so my question is:

What would be the best way to achieve this, by script ( http://wiki.unity3d.com/index.php?title=Animating_Tiled_texture) or creating a special shader that basically does the same thing?

Please give me some clue.

Thank you very much.

8
Support / Animated tiles
« on: October 17, 2014, 06:39:38 pm »
First of all, excuse me because maybe this is a very basic question, but I'm a noob on Unity and 2d Toolkit.

I guess there are two techniques to animate tiles:


Could explain me this technique?
Thank you very much.

9
Support / Re: FSM: One scene for each state?
« on: July 30, 2014, 05:20:26 pm »
Thank you, here the answer on Unity forum:

Steve Tack
Quote
The term "state" is very general, so it might help if you were more specific. It sounds like you're talking about using states for different "screens"? Like menu screens?

You could try it and see how it goes. Sometimes optimizing when you don't really need to is a waste of time. But if you do run into performance issues, you can draw "screens" by making your UI elements active or inactive. So if you had an Options state, maybe you'd activate a parent GameObject that contained all of your Options UI and inactive everything else.

Often an FSM has a place to put "I'm entering this state" code. So you could do that there for each UI state.

I ended up writing my own screen manager that works with NGUI to make that sort of thing easier, which could be overkill depending on how complex your UI is.

The only mobile game I've done only uses a single scene. There's an FSM to manage what to do when.

Thank for the reply.

10
Support / FSM: One scene for each state?
« on: July 28, 2014, 06:37:01 pm »
I'm a noob with Unity + 2DToolkit who came from Air / Starling.
I want to implement a FSM and after had read many tutorials, I have a doubt.

My game target is iOS / Android and some tutorials does one scene for each state, but Is this good strategy for mobile development?
Maybe I'm wrong but I'm thinking that is bad for performance.

Is it a good approach one scene for each state?
Are there some alternative more efficient?

Thank you.

11
Support / PDF Documentation
« on: June 20, 2014, 12:43:58 pm »
Hi everybody,

First of all, excuse my english  :-[

I'm a noob with 2dToolkit/Unity who before was working with Air/Starling.
I have purchased your tool and I want to know: Is the documentation available in PDF or best in Mobi? I have a Kindle, and it is easier read the ebook, than the screen  :D

Best greetings.

Pages: [1]