Chounard

  • 7 Şub 2017
  • 28 Şub 2013 tarihinde katıldı
  • I think trianglesCount will give you the number of indices. Since spMeshAttachment doesn't have verticesCount the runtimes use uvsCount instead.

  • kickstarter tartışmasında
  • I don't use "Create Atlas" in the Export settings. I go to the Texture Packer setting in the menu, and save the atlas from there.

  • Sorry for not responding sooner, Nate. Been out on holiday trips.

    Sure thing. Everything in that repo is public domain, so you're welcome to do whatever you like with it. 🙂

  • I love TPP! I even wrote an importer for TPP files for the Unity 4.3 Sprite system.

    I meant getting it to work with Spine+Unity is fiddly. (Though I've done it.) 😛

    Atlas renamer importer script:
    https://github.com/ThirdPartyNinjas/Uni ... mporter.cs

    Put that in an Editor folder somewhere in your Assets (I use Assets/Scripts/Editor/Importers/) and when you export an .atlas file into your project, Unity will delete the old version and rename the new one to .atlas.txt as soon as it gets focus.

  • I use the built in Texture Packer to export all of my animation textures together, which will help save on draw calls. (In settings, I check "Combine subdirectories.") Also, you're using the built in Texture Packer, and not the program (of the same name) from texturepacker.com right? (That can be made to work, but it's fiddly, and not worth the effort, IMO.)

    There's no need to rename the .json file to .txt, if you're using the current version of Unity. It supports .json files as text assets now. You need to rename the .atlas file, though. I use a custom importer to rename it for me, so I don't ever have to do it manually.

  • There's a plugin you can buy called 2d Toolkit which has been out for a long time.

    I think you're probably wondering about the 2d sprite system from Unity themselves. Yes, that came with 4.3. It's pretty nice, but not really extensible enough to be used by Spine directly. Luckily, we can mix the Spine renderer with it pretty easily.

  • I'd need more info on how your project is setup. Are you working with an orthographic camera and the new sprite system? If so, toss this script on your spine animations, so you can set the sorting layer/order just like the sprites.

    https://github.com/nickgravelyn/UnityTo ... %20Exposed

    If not, you might be able to sort it out just using the Z depth to move things in front of others.

    • Düzenlendi

    That video is a little outdated. (But still really helpful! I used it too.)

    You no longer need rename .json files to .json.txt. Unity recognizes .json as TextAssets now. (Also, you can use an importer to handle renaming .atlas files. Mine is here if you like.)

    Make sure your texture is set to "Texture" under Texture Type, and not something else. (It defaults to "Sprite" if you're working in the new 2d mode.)

    After assigning your texture to your material, choose the Spine/Skeleton rather than Transparent/Diffuse shader. If you're using something else, you might need to add a light to your scene for it to show up.

    Give those a shot and see if it helps.

    Edit: Updated Importer URL.

  • There really isn't a "best" way. Here are three common methods (which have nothing to do with Spine):

    1) If it will work for your game, the simplest method is just axis-aligned bounding boxes. (Exactly what you suggested.)
    2) You can use several rectangles (or circles, which are much faster) to make the collision shapes, and test those.
    3) Finally, you could create a collision polygon for each character, and use the separating axis theorem to find out if they are colliding. I wrote a bit about this method a long time ago here: http://thirdpartyninjas.com/blog/2010/0 ... on-update/ (Read the linked references. They do a much better job explaining it than my code would.)

    Unless you're planning something pretty complicated, one of those should be perfect for what you need.

  • Doesn't seem to (at least when animating with AnimationState.)

    I just replaced the Update method in the XNA example with this (C# code):

    		KeyboardState oldState;
    		bool jumping = false;
    
    	protected override void Update(GameTime gameTime)
    	{
    		// Allows the game to exit
    		if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
    			this.Exit();
    
    		// TODO: Add your update logic here
    
    		KeyboardState ks = Keyboard.GetState();
    		if (!oldState.IsKeyDown(Keys.Space) && ks.IsKeyDown(Keys.Space))
    		{
    			if (jumping)
    			{
    				state.SetAnimation(0, "walk", true);
    				skeleton.SetToSetupPose();
    			}
    			else
    			{
    				state.SetAnimation(0, "jump", false);
    				skeleton.SetToSetupPose();
    			}
    			jumping = !jumping;
    		}
    
    		oldState = ks;
    
    		base.Update(gameTime);
    	}
    

    Hit space to switch between walk and jump. (He starts in the drawOrder animation, in the current example.) When you switch to jump, hit space again quickly, and you'll see him walking at an angle.

  • I would have expected that to work, but I'm not fully sure what's going on under the hood.

    What I was suggesting you change is the actual animation itself. (In the Spine application, just set a rotation keyframe in the walk animation.)

  • Also, nice work on those docs, Nate. First time I've seen that, and it's quite excellent.

  • Just to make sure I understand what you're seeing:

    1) You switch from walk to jump, and it looks good.
    2) You switch from jump back to walk, and he's now walking at an odd angle.

    Is that right? If so, then (as Nate wrote) everything is working properly.

    I ran into this too, and thought I'd messed something up on my end. This is caused by the root bone being rotated during the jump animation, but there are no rotation keys set for the walk animation. You can easily fix this by setting at Rotate 0.0 key on the first frame of the walk animation, or you can modify the jump animation to remove rotations from the root bone. (I prefer to rotate from hip bone instead and always keep the root unmodified.)

    Please let me know if this doesn't make sense.

  • You probably don't really want point filtering. Nearest-neighbor looks terrible in motion. Some blurring is to be expected, because blending is required if you draw at non-integer positions, or use rotation or scaling.

    For example, look at the tentacle tree here. You can see how terrible it looks in point filtering. (Also, how awesome is a tentacle tree? My wife/artist is awesome.)
    Linear:
    https://dl.dropboxusercontent.com/u/959 ... /trees.png
    Point:
    https://dl.dropboxusercontent.com/u/959 ... _point.png

    You mention twice that if the texture is a square that it looks better. I wonder if that's part of the problem. Are you using the texture packer built into Spine? If so, make sure you're using the options to pad to pow2 and square, and see how that looks.

  • Tweaking the XNA runtime tartışmasında

    I moved all the loader code over to my own project, and put that up on github.

    Here's a post I made about it, which you're welcome to link to if that's useful:
    http://www.esotericsoftware.com/forum/v ... f=3&t=1348

    I don't think there's anything else left in my fork of the runtimes, so I'll go ahead and delete it and move back to using the original.

    Thanks, everybody.

    • Düzenlendi
  • I've written a bit of code to simplify loading Spine Atlas and SkeletonData files through the XNA Content Pipeline.

    Note: This is unfortunately finicky to set up, so I only recommend it if you're already familiar with the Content Pipeline, and you prefer to use it. Also, while Atlas is perfect, using the Content Pipeline for SkeletonData will mostly just be for the convenience of having a ContentManager act as an asset cache for you. Spine's classes are not designed in a way that would allow for use of the automatic XNB serializer, and doing the work to create ContentWriter/Reader classes for each of Spine's classes isn't really worth the effort.

    If you'd like to use the code, you'll need four files.

    https://github.com/ThirdPartyNinjas/Nin ... ions/Spine

    1) AtlasPipeline.cs
    2) SkeletonDataPipeline.cs
    Add these to a Content Pipeline extension project.

    https://github.com/ThirdPartyNinjas/Nin ... harp/Spine

    3) AtlasReader.cs
    4) SkeletonDataReader.cs
    Add these to a Game or Library project.

    Make sure your Content Pipeline extension project is added to Content project references, then you can set the importers and processors. For atlases, choose "Atlas Importer - Spine" and "Atlas Processor - Spine." And for SkeletonData, choose "SkeletonData Importer - Spine" and "SkeletonData Processor - Spine."

    Next, in the ContentProcessor parameters (expand the drop down next to the processor) you need to set the name of the atlas. This is the same asset name you would use to load in game using a ContentManager.

    Finally, load the SkeletonData using a ContentManager: (No need to load the atlas yourself.)

    SkeletonData skeletonData = Content.Load<SkeletonData>("MySkeletonData");

    One more note, in that second folder, you might have noticed a class called SkeletonRenderer. That's what I use to render Spine skeletons using a replacement SpriteBatch class that I wrote that allows for Matrix transforms per draw. This makes it easy to apply transforms to the skeleton without a bunch of SpriteBatch.Begin/End killing your frame rate.

  • Tweaking the XNA runtime tartışmasında

    Since I don't think there's many people who would benefit from the content pipeline changes, perhaps it would be better if I moved that stuff over into my own project. (I already moved my SpriteBatchRenderer over, since it was easier to add the features I needed there.) The stuff I'm working on will be open sourced, so we can just point people over to the content pipeline files if they want them.

    How would you feel about making a minor change to Atlas.cs? I'd just need an additional constructor:

    public Atlas(List<AtlasPage> pages, List<AtlasRegion> regions) 
    {
    	this.pages = pages;
    	this.regions = regions;
    	this.textureLoader = null;
    }

    And a check for null during Dispose:

    public void Dispose ()
    {
    	if (textureLoader == null)
    		return;
    
    for (int i = 0, n = pages.Count; i < n; i++)
    	textureLoader.Unload(pages[i].rendererObject);
    }