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

Pages: [1]
1
Support / Re: Attempting to create an outline around my sprites
« on: February 21, 2016, 09:38:47 am »
Hi unikron, I'm having the same problem now and want to know logics behind this weird result. (TBH It's first time touching unity shader system, but I'm learning while trying to fix this)

So I put 2 sprites in the scene - one using tk2dSprite, one using unity5's SpriteRenderer.

Assign these objects to this library's script. Then in MonoBehaviour OnPreCull() method

1. It automatically moves my outline objects to temporary layer
2. Apply Buffer shader to my outline objects.
3. Captures temp layer to RenderTexture instance using temp camera.(<- Seems like this is the bug point)
4. Then draw outline using outline shader in OnRenderImage() method with Graphics.Blit()

I've checked step 2's Buffer Shader Surface code, It looks like this :

Code: [Select]
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * IN.color;
float alpha = c.a * 99999999;
o.Albedo = _Color * alpha;
o.Alpha = alpha;
}

And in step 3's shader(which draws an actual outline) I just modified a bit to draw alpha value as red value. Screenshot of this test :



So it seems like there's a problem in capturing camera to RenderTexture in OnPreCull() method, It has transparent pixels as Colored pixels. Well, I think it's for some reason but I'm not smart enough to figure this out...How can I fix this? I'd appreciated if you help.

2
Support / Can I use box collider with advanced collider?
« on: September 03, 2015, 09:34:20 am »
Hi, I'm making 2d sidescroll action game now and I'm using advanced collider for my game because I need multiple boxes for hitbox & hurtbox.

But Also I'm using Raycast method for checking collisions, which means I also need Unity's integrated box colliders for my collision map.

So, If It's all about my tilemap & character collision, everybody will be happy but I want to integrate character & character collision so here's the problem - to use Physics.Raycast method I need box colliders also for my characters.

I can manually add and define box colliders to my character objects(*tested this already and character - character collision works well), but Every characters' hurtbox changes very dynamically per their action and it seems like 2dToolKit automatically changes box colliders for me when I use 'Box Custom' option for my Collider Type option. I need that function.

So, It will be very convenient to use advanced colliders with box colliders...How can I do this?

(*Sry if my english was bad, If there were some part you can't understand please tell me!)



3
Support / Flip of Advanced collider
« on: January 28, 2015, 02:35:12 pm »
Hi, I'm using advanced collider for multiple colliders and realized when i set flipX from sprite animator, it seems like origin of advanced collider doesn't flip.

EX) When I Log tk2dSpriteColliderDefinition.origin, let's say initial value is (0.6, 0.6). it should be (-0.6, 0.6) when i flip sprite horizontally but still it gives me (0.6,0.6).

Is this intended or a bug?

4
Support / Re: Problem with using sprite thumbnail code
« on: December 11, 2014, 02:16:57 pm »
OK that was not a complex problem. I got tk2dSpriteDefinition reference by this :

Code: [Select]
spriteDef = currentFrame.spriteCollection.spriteDefinitions [currentFrame.spriteId];      
But if you use GetSpriteDefinition(string) just like tk2dSpriteEditor does...

Code: [Select]
spriteDef = currentFrame.spriteCollection.GetSpriteDefinition (spriteDef.name);
then it works. I needed spriteDef.name to use GetSpriteDefinition so as a conclusion it became little bit hacky code like this :
Code: [Select]
spriteDef = currentFrame.spriteCollection.spriteDefinitions [currentFrame.spriteId];
spriteDef = currentFrame.spriteCollection.GetSpriteDefinition (spriteDef.name);

5
Support / Problem with using sprite thumbnail code
« on: December 11, 2014, 10:52:56 am »
Hi, I'm currently making my own tool for editing character's attack moves. The Editor Looks like this :


(Yeah, I extended and copy-pasted some parts of 2d toolkit editor codes to make this editor)


I wanted to preview selected frame(In the image, it's frame 0) of tk2dSpriteAnimationClip instance, but as you see the thumbnail box is empty.

This is code to draw thumbnail box :

Code: [Select]
public void Draw()
{
GUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel(" ");

int tileSize = 128;
Rect r = GUILayoutUtility.GetRect(tileSize, tileSize, GUILayout.ExpandWidth(false));
tk2dGrid.Draw(r);
tk2dSpriteThumbnailCache.DrawSpriteTextureInRect(r, spriteDef, Color.white);


GUILayout.EndHorizontal();
}

...which is copy&pasted from tk2dSpriteEditor.DrawSpriteEditorGUI().

I inserted some logs to find out why, and realized when tk2dSpriteThumbnailCache.DrawSpriteTextureInRect is called, spriteDef.materialInst is null which causes this problem(maybe).

So this is how i get reference of tk2dSpriteDefinition :

1)Before Open the editor, drag&drop SpriteAnimation prefab i created. In the image, you can see "PlayerAnimation" on the right.

2)When you click "New Attack Move" button and set clip from EditorWindow.popup() (in the image, the clip is 'neutral'.), AttackMove class is instantiated and this instance holds reference of tk2dSpriteAnimationClip

3)Create frame list from tk2dSpriteAnimationClip.frames.

4)When a user clicks frame, check the index of frame and get tk2dSpriteAnimationFrame reference

5)tk2dSpriteDefinition spriteDef = currentFrame.spriteCollection.spriteDefinitions [currentFrame.spriteId];

6)use spriteDef to draw thumbnail image



I wrote as much detail as possible. Any missing steps here? Thanks for your help in advance!

6
Support / Trigger for Advanced Collider?
« on: December 05, 2014, 03:46:39 pm »
Hi, I'm using advanced collider for character collision box and also for hitbox, and this system is very useful.

Currently, to detect hitbox collision, I simply loop around every enemy gameobjects and use rect.overlaps().

Well, I have not much enemy objects so it's okay so far...but I hope if I could use trigger or something like that for more clean code.(Just like original Unity Box Collider system offers)

Is this feature supported?

7
Thanks for the reply, I checked out gitignore_global.txt file in my Documents folder(Windows) and discovered dll files were on the list.

I deleted *.dll line and changed the project a little bit then commit, then push&pull - now It works! Thanks for the help!

8
So I've already seen this topic http://2dtoolkit.com/forum/index.php/topic,1851.0.html but this one was not related to git...

I used my notebook to first setup my project, then push it to bitbucket repository, then pull from my desktop.

(*I've already setup Edit-project settings-Editor-Version control to 'Visible Meta data' and Asset serialization to 'Force Text' before pushing to git)

This is my .gitignore file :

Code: [Select]
# =============== #
# Unity generated #
# =============== #
Temp/
Obj/
UnityGenerated/
Library/
 
# ===================================== #
# Visual Studio / MonoDevelop generated #
# ===================================== #
ExportedObj/
*.svd
*.userprefs
*.csproj
*.pidb
*.suo
*.sln
*.user
*.unityproj
*.booproj
 
# ============ #
# OS generated #
# ============ #
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

The problem is , tk2dExternal.dll and tk2dSkin well exists on my notebook(also .meta file) but on the bitbucket repository I only see .meta for tk2dExternal.dll and tk2dSkin.dll, no dll files uploaded.



Maybe It's auto-generated by 2dToolKit? But when I pull from my desktop It just shows me an error :



I don't know how to fix it. Any help please?

9
Support / Re: How to make sprite from tilemap?
« on: July 07, 2014, 03:08:19 pm »
Works Like a charm! I didn't implement the 'Smooth Moving' yet, but I succeeded to make a GameObject which is created from tilemap.

Here is code, if any other guys need help in the future:)


Code: [Select]
using UnityEngine;
using System.Collections;
using tk2dRuntime;

public class ClickManager : MonoBehaviour {
public tk2dTileMap tilemap;

private GameObject createdSpriteGO = null;

// Use this for initialization
void Start () { }

// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(0)){
if(createdSpriteGO == null){
createdSpriteGO = createSpriteFromTilemap(3, 0, 3, 1);
}else{
Destroy (createdSpriteGO);
createdSpriteGO = null;
}
}
}

GameObject createSpriteFromTilemap(int originalX, int originalY, int destX, int destY){
GameObject tmpGO = new GameObject();
tk2dStaticSpriteBatcher batcher = tmpGO.AddComponent<tk2dStaticSpriteBatcher>();
int tileNum = (destX - originalX + 1) * (destY - originalY + 1);
Debug.Log("tileNum to batch: " + tileNum);

batcher.batchedSprites = new tk2dBatchedSprite[tileNum];

int idxCounter = 0;
for (int x = originalX; x <= destX; x++) {
for(int y = originalY; y <= destY; y++){
tk2dBatchedSprite bs = new tk2dBatchedSprite();

// assign sprite collection and sprite Id for this batched sprite
bs.spriteCollection = tilemap.Editor__SpriteCollection;
bs.spriteId = tilemap.GetTile(x, y, 0);

Vector3 pos = new Vector3(x, y , 0);

// Assign the relative matrix. Use this in place of bs.position
bs.relativeMatrix.SetTRS(pos, Quaternion.identity, Vector3.one);

batcher.batchedSprites[idxCounter] = bs;

idxCounter++;
}
}

// Don't create colliders when you don't need them. It is very expensive to
// generate colliders at runtime.
batcher.SetFlag( tk2dStaticSpriteBatcher.Flags.GenerateCollider, false );

batcher.Build();
return tmpGO;
}
}


10
Support / Re: How to make sprite from tilemap?
« on: July 07, 2014, 04:57:38 am »
Wow I could use static sprite batcher for this?? AWESOME! I'll try this way when I go back to home. I'll post the result then :)

11
Support / How to make sprite from tilemap?
« on: July 06, 2014, 01:32:29 pm »
Hi, I want to move some part of my tilemap tiles smoothly, in all 4 directions.

It's not something like moving platform - Players decide which tiles to move, and also direction. So please don't tell me something like 'Just create a gameobject that moves!'.

For the smooth moving, I don't want to use getTile() and setTile() method only because in that way tiles just disappears and appears suddenly.

So My solution is little bit tricky :
1)Create a Sprite from part of the tilemap.
2)Overlap the sprite over the tiles which I originally wanted to move.
3)Make original tiles disappear, using setTile(originalX,originalY,-1).
4)Sprite starts to move.(Smoothly!)
5)If sprite reaches its destination, destroy the sprite and reappear tiles using setTile(destX,destY,originalTileType)

Then player can never notice how things work, but they'll only see tiles moving smoothly.

But the problem is I don't know how to create sprite from tilemap... I can get integer tileType data, but I don't know how to create sprite from it.

Can anyone help me please? :)

*oh and sry if my english is poor, it's not my native language:(

12
Support / Re: Custom Tilemap Collision?
« on: June 30, 2014, 04:25:40 pm »
Well It's little bit sad that I have to implement my own collision which certainly will take some time :P But Anyway thanks for the answer, and also thanks for the great tool.

13
Support / Custom Tilemap Collision?
« on: June 30, 2014, 02:37:08 pm »
Hi guys, I'm new to unity3d and 2dtoolkit, and I just followed tilemap tutorial on documentation board, and also read about Tilemap class reference.

What I want to implement is - moving tiles around freely, just like the game Minecraft.(This is 2d so more like Terraria.)

Player can pick a tile, and move that tile to wherever he wants.(Of course the tile will be snapped on tilemap grid automatically. Oh, and the map is not infinite - Character moves room to room so map won't be too big.)

I think i can achieve moving tiles by just using getTile(), setTile() and Build().

But, the reference says, "Build only rebuilds affected partitions and is efficient enough to use at runtime if you don't use Unity colliders."

Also this - "Avoid building tilemaps every frame if you use Unity colliders as it will likely be too slow for runtime use. "

So What I'm curious about is, Certainly there will be so many Build() calls in my game, but it won't be called "Every Frame". I use Box Trimmed collider which is pre-defined on sprite collection editor, and I'm worried if it will cause speed problem like the reference says.

Is it too much concern? I hope it is. Anyways, I'll wait for the answer :)


Pages: [1]