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 - mrkake

Pages: [1] 2
1
Support / Re: Fade out during tk2dSpriteAnimation ?
« on: November 21, 2015, 11:59:57 pm »
Hey thanks! It took me a bit to understand , though it's really quite simple in the end, and I had to buy the pro version of DOTween for $15, but, its working !!!

Very nice, thanks :)

2
Support / Fade out during tk2dSpriteAnimation ?
« on: November 16, 2015, 02:02:44 am »
I can't figure out how to do this easily.

I read a few other threads, and it seems fairly straight forward to get a sprite to fade out, lets just say set the alpha to 50% to be simple:

just on the tk2dsprite:
Color color = sprite.color;
color.a = newAlpha; // calculated elsewhere
sprite.color = color;

This actually works fine, the problem is, that during tk2dSpriteAnimation, every time the frame changes, the material is reset. Additionally the material is somewhere cached and every instance of the animation fades out at the same rate.

Even if I just run the fade out code on a single animation, every instance of that animation which is playing starts to fade out.

Is it possible to get a method to do a fadeout? Basically, I want to specific the start % and end % of the fadeout.  i.e.  start fading out 80% of the way through the animation and finish fading out 100% of the way through the animation.

I know that I can get my code working if I created a new material for every frame (and for every instance) of the animation and reset the material whenever SpriteChanged event fires. However, this is a LOT of materials when we are talking about the types of effects I want to fade out.

The other argument could be that the fade should be in the animation itself. This is the next step if its really not possible in the code. However, Currently, I have one really big animation, for example a giant explosion. What I would really love to be able to do is have small and large explosions all using the same sprite sequence. Then, what I can say is "play from this frame to that frame" with a fade starting at a certain percentage... if this worked, I could use a single actual animation (sprite sheet) , and create many many many different animations.

Anyway, I don't think it's currently possible in 2d toolkit. But please let me know if it is or any thoughts?

Thanks!

3
Releases / Re: 2D Toolkit 2.5.3
« on: May 24, 2015, 10:43:50 pm »
tested , its working now :)

thanks! you rule :)

4
Releases / Re: 2D Toolkit 2.5.2
« on: May 24, 2015, 08:08:23 pm »
Hi,
I'm not totally sure but I think there can be a bug introduced here, as my game stopped working.

I checked the line where I'm getting the error - tk2dTileMapMeshBuilder.cs line 61.

colorChunk is null, and there is a null reference exception trying to read the values from it.
Strange because line 31 above is checking it's null, but it doesnt stop the code from continuing.
And I see like 79, if (useColor), but this would clearly never be reached.

5
Support / Re: Switching Sprite Collections in script
« on: May 24, 2015, 05:37:41 am »
ah, i'm just going to reply and answer my own question.

I found this method documented on the spritecollection help page:

tk2dSystem.LoadResourceByName<tk2dSpriteCollectionData>(string s)

This actually works great, then just check the loadable asset checkbox inside the settings of the sprite collection. So there is no need to move it to the resources folder. :)

6
Support / Re: Switching Sprite Collections in script
« on: May 24, 2015, 04:50:35 am »
I know this is an old thread, but I just found this thread while looking for an answer. I'm trying to do something similar, change to a new sprite collection but I dont have a reference to the object just know the name.

Currently, my sprite collections are NOT in the resources folder, but when I move them to the resources folder they are no longer editable and a message appears which says move them out of resources to continue.

Can you please elaborate a bit on the correct process to edit the collections? Should my flow be when I need to edit move it out of resources and move it back in?

7
thanks that was really helpful, I did not realize that the sprite gave access to the spritechanged event, this really worked great. :)

8
Ok I'm having a new problem and I might have to just write a lot of annoying code to fix this, but I wanted to bring it up to see what options are.

The problem I'm having is that, for example with the crate, I have attached this new shader to every crate. Inside the game code, I have some code which changes the settings inside the shader, but the issue is that these settings do not stick when the sprite is changed.

2d toolkit is called the UpdateMaterial() method which detects that something in the material has changed, and then swaps the material back to the original material for the sprite collection which reverts my settings.

I'm not sure how to fix this other than calling my own additional update material method or something after changing the 2dtoolkit sprite.  But I was wondering why it's doing this, I read inside the code some comments that said the purpose of the code is to change the material when switching between sprite collections, but it's clearly not actually checking to see if the sprite collection has been changed, it's just checking if the material is the same exact material... if the code actually checked the sprite collection instead I wouldn't have this problem. But I'm not sure what the impact of that would be for other things.

9
I'm not sure what you mean about this, how can I know from the world position when the texture/sprite is perspective based?

It is a 2d game, but we create "rotated" sprites to give the perception of depth inside the game. So, when the sprite is facing forward, the depth is simply, the Y axis  (up / down), but, when rotated 45 degrees, the sprite depth is more like a V shape, when the whole V is the bottom of the crate

check the attached images,  notice the difference in boat and the crate rotations, how the water level when its head on is a line ---- and when turned a V.  But the world position of the sprite is exactly the same, its just using a new sprite from the sprite collection. So as far as I know we need to use the gradient map to determine it?

10
Ok -- update, I have the shader now, but, I'm a bit unclear how to get it working with sprite collection.

the problem is like follows in this example:

we have a crate sprite collection. There are 16 sprites in the collection depending on the rotation of the object. In order to get this to work with the shader, we have also created a grayscale gradient map for each rotation (black is the lowest height and white the highest height).  It's trivial to add the gradient texture/material when its just one sprite, but I'm a little confused how to add it for the sprite collection.

2d toolkit creates a compressed atlas from the sprite collection so do i need to somehow convert the gradient map to be in the same orientation when all 16 are packed? how do i do this? or how can I specify this graident map file actually contains 16 graident maps, one for each rotation in the collection?

11
I guess this is what I was thinking originally, but I was hoping for a different solution I guess, since I don't really have shader knowledge.

Maybe I can find someone to pay to help write a shader

12
Hi,

I am hoping to find some ideas how to approach the following problem.
We are working on a game which takes place on the water.

For example a boat, and when in the water, about 1/3rd of the bottom of the sprite has a transparent blue color over it to make it appear the boat is in water.
Currently, we drew this in the sprite itself, but its quite tedious as there are multiple rotations for each sprite and there are many other sprites which can be in water.

Ideally, I would like to somehow apply automatically the "blue" over the sprite depending if the item is in water or not, and additionally, would like to create a bopping effect for idle animation, which means the blue percentage shift up and down a few pixels each 1/2 second or something like this.

At first I thought this could be solved by just creating a square blue , putting on the layer above the sprite and setting the alpha channel to make it slightly transparent but the problem is that the area of water surrounding also obviously gets this rectangle of blueness on it. Ideally, I can somehow disable the pixels in the blue square when there is not a target sprite below the pixel. Is there some way to achieve this effect?  Or a different approach entirely.

Thanks

13
Support / Re: Which shaders are NOT vertex lit / fixed function?
« on: February 25, 2015, 01:21:33 pm »
When using Blend2TexVertexColor I got the following error:  Unsupported: 'tk2d/Blend2TexVertexColor' - Pass '' has no shader programs (Fixed-Function not supported)

Actually it's possible that BlendVertexColor is supported.

I get a lot of warning messages no matter what shader I use, but I realized that even if I pick a supported shader it shows a warning like "Unsupported: 'Diffuse' - All passes removed".

But when I look quite close at the full output I see it is making it farther so perhaps there is a bug in my code as well but I'm not sure. Trying to get my game running at all on the system at this point, it works fine on PC.

I will post an update if I can resolve this , I'm thinking now its not the fault of 2d toolkit

14
Support / Which shaders are NOT vertex lit / fixed function?
« on: February 25, 2015, 04:45:06 am »
Sorry if this is an amateur question, but I really don't understand the names and differences between the shaders terminology at all.

I am trying to run a game I created with 2d toolkit on the wii u, and its crashing, when i checked the error log and for help on the official forums, the reason is because vertex lit and fixed function shaders are not supported currently with unity games.

I can see the 2d toolkit had a lot of different shaders in the tk2d menu, and that unity itself also comes with a lot of shaders. But, I don't particularly want to brute force try them all (though i can if it comes to this) since I will have to change the shader on every texture/sprite.

I am wondering, which textures are NOT vertex lit and NOT fixed function? Also GLSL shaders are not supported, whatever that means. So I need a shader which is not one of these three. Is one already in unity or tk2d? Or any ideas how I could obtain one? And is there any way I could have known this without asking? And if its not too in depth to give a high level overview, what does "fixed function" even mean in terms of a shader? (vertex lit i kind of understand)

thanks so much


edit:  also i'm using tilemap, and regular 2d toolkit sprite renderers on prefabs combined.  i'm wondering if the tilemap is respecting the shader on the material attached to its sprite collection?  no matter what i pick i am getting errors running on the console about unsupported vertex shaders. i have picked "diffuse" "transparent\diffuse",  neither of these work but i feel they should.  tk2d\blend2vertexshader definitely does not work. sprites\diffuse also definetely does not work. any ideas greatly appreciated

15
Support / Re: Tilemaps and passing Prefab Data
« on: February 11, 2015, 01:24:36 pm »
I just want to try to explain why this is not convenient but I'm not sure it will be clear.

In our game, we need to create a prefab at every instance of these tiles, for example, we have a tile where the player starts and a tile where an enemy is. We need to create the player prefab or the enemy prefab,  but,  we are also using StrangeIoC and we need to perform an AddComponent on these objects, to add a specific script to the prefab dynamically, and it needs to be performed in the context of strangeioc otherwise the mediator does not get created.

So, my idea to solve this was to create a single "fake" prefab with a common script on it which contains some info about what the real prefab should be. Then, on startup after tk2d is ready,  a script inside strangeioc can locate all of these "fake" prefabs, and read the data from them , match it to a config value,  and then create all the "real" prefabs and destroy the "fake" prefabs. 

It can't be solved with a tag because you would then need a different fake prefab for every type.

The solution we have created now, is to remove the prefab from the tile in tk2d, put the special tiles on a layer behind so its not visible, store the data in the fields which I mentioned, but when the scene is loaded,  a nested loop through every single tile on the tilemap and check each tile if it contains some interesting data, and then create the prefabs inside our script under the strangeioc context where the mediator will be properly bound to the prefab/view.   Actually to me this isn't a totally terrible solution since the scan happens just once at scene load and it's relatively fast, but it is less than ideal.  (Perhaps another solution is create the "fake" prefabs with a script that lookup the tk2d tile based on transform position, in theory this could be faster than the nested loop?)

If instead the prefabs had that data already in it, things would be faster. But since we want external designers to be able to create levels and export them in .TMX , they need to be able to create these things once - we can't click on every prefab in the render data and set these values, which is why the tilemap data seems to be an ideal place, since that data is set once for every tile of that type.

Pages: [1] 2