tayl0r

In Unity (4.6), is it possible to render a particle (or another 2d sprite or a 3d object) in between 2 pieces of a spine animation?

For example, maybe a character is holding a torch with a fire/smoke particle, and I want those fire/smoke particles to render behind the character's head but on top of his hand.

I see this here, http://forum.unity3d.com/threads/drawing-order-of-meshes-and-sprites.212006/ - is that relevant ?

If this type of thing isn't possible, then it seems we would need to split our spine animation up so the background and foreground pieces are in different spine animations. Then, export them both separately. The thing that sucks about that is now you have 2 different spritesheets (with maybe some sprite duplication) so they probably wont be as efficiently packed. Unless, you could somehow make them share the same "master" spritesheet- is that possible?

---

I see in SkeletonRenderer.cs that there is a field for zSpacing. I set that to a higher value and then my spine animation mesh was very split up. But, the particle still renders completely on top or behind the entire mesh, not the individual pieces.

That test was done using Unity 4.5.5. Could this behavior be differet in 4.6?
tayl0r
  • Postovi: 11

Pharan

This was requested a few times before so we stuck the feature into Spine-Unity.
It's not as efficient as it could be yet (Mitch used an extra non-rendering Material to hide certain parts, which breaks batching and may cause a few useless draw calls) but it works.

Here's a sample from when it was first implemented:

In this sample, the raptor skeleton was rendered in the middle of the hero's skeleton.

WARNING: OUTDATED INFO (Feb 2015)
Right now, the way to tell SkeletonRenderer to split the rendering in two is go to Spine and add an (empty) slot named * or starting with an asterisk, like: *particles go here. Then put it in the right place in the skeleton's Draw Order.

In Unity, this will cause it to generate an extra GameObject with a MeshRenderer on it.

Then you set the Sorting Layer and Sorting Order accordingly so the back part is drawn first, then inserted parts (like your particles) and then the front part. You'll need an extra script or something to do this, since Unity doesn't expose it in the inspector.

Despite being hidden in the inspector, all Renderers since 4.3 actually have .sortingLayerID, .sortingLayerName and .sortingOrder properties that can be changed and it will behave correctly. Read more about them in the docs: http://docs.unity3d.com/ScriptReference/Renderer.html

Though I vaguely remember the particle renderer acting a bit differently. In that case though, that would be a Unity thing and it wouldn't work even if you were to use two different skeletons.

PS
Alpha-blended shaders like the one Spine-Unity uses don't write to the depth buffer so using zSpacing can never be used for the effect you're looking for (ie, to tell it what parts should be drawn behind or in front in other objects).
Avatar
Pharan
  • Postovi: 5366

tayl0r

Perfect. Breaking batching here is not such a big deal for us. Thanks Pharan!
tayl0r
  • Postovi: 11

Pharan

My bad. You actually need SkeletonUtility to do the spitting. It's not working as I understood it, but at the minimum, you do need to add SkeletonUtility and use "Spawn Submeshes". Sorry I can't help you beyond this at the moment. Maybe Mitch has some input.
Avatar
Pharan
  • Postovi: 5366

alex.seeck

I feel a bit stupid,

I did exactly that. Created an animation in Spine, created a bone named * in between several others, imported that in Unity, activated the Skeleton Utility and clicked "Spawn Submeshes". All I got though was one child GameObject named "Submesh 0" containing everything without any splits.
What did I do wrong?
alex.seeck
  • Postovi: 29

Mitch

The * method is obsolete now. Latest runtime has a new array accessible in SkeletonRenderer called Submesh Separators. Same principle, easier to use.
Avatar
Mitch

Mitch
  • Postovi: 978

nic

Hi Mitch,
We currently have a bug when using submeshes (6 submeshes) + Skeleton utility / Hierarchy / follow bones.
Without submeshes the bones in the skeleton utility follow correctly the animation.
When I split my spine with submeshes, there is a 1 or 2 frame offset between the animation and the follow bone.

Is it fixed?
If i split my spine with *, do I need to update to the new system?

Thanks

Nicolas
nic
  • Postovi: 13

Mitch

If i split my spine with *, do I need to update to the new system?
Yes.

I didn't know there was a lag issue with submeshes. I'll look into it soon.

---

I'm not seeing a difference between the lag With and Without submeshes. Not to say there isn't a frame of lag, but there doesn't seem to be a difference between the two methods. Do you have a project that clearly exhibits the issue you could send me? Or take some video?
Avatar
Mitch

Mitch
  • Postovi: 978

alex.seeck

Mitch je napisao/la:The * method is obsolete now. Latest runtime has a new array accessible in SkeletonRenderer called Submesh Separators. Same principle, easier to use.
I also did that. I chose 1 Separator, selected the * and clicked split. Still just one Submesh 0.
alex.seeck
  • Postovi: 29

Mitch

alex.seeck je napisao/la:
Mitch je napisao/la:The * method is obsolete now. Latest runtime has a new array accessible in SkeletonRenderer called Submesh Separators. Same principle, easier to use.
I also did that. I chose 1 Separator, selected the * and clicked split. Still just one Submesh 0.
Click Reload before clicknig Spawn Submesh whatevers?
Avatar
Mitch

Mitch
  • Postovi: 978

alex.seeck

Hi again,

I ran into the same problem, this time it doesn't matter what I select, I won't get a second submesh, just Submesh 0. What I do:

- Spine Spawn SkeletonAnimation of a SkeletonData Asset
- Set Submesh Seperators array to 1 and select any slot
- Click on Add Skeleton Utility
- Click on Spawn Submeshes in it

I only get Submesh 0. The functionality ceased to work today. Even after updating to the newest runtime, it does not work. Is there something that mustn't be done with a Spine Animation that breaks this?
alex.seeck
  • Postovi: 29

Mitch

Not to my knowledge :(

Unity 4 or 5? I'll look at it when I get back to the office tomor...ow... (its 3am, i'm going home)

can you email me your skeleton / atlas files? (don't need the textures if you can't send them, just the .atlas.txt)
Avatar
Mitch

Mitch
  • Postovi: 978

alex.seeck

Mitch je napisao/la:Unity 4 or 5?
It's 5.0.1f1
Mitch je napisao/la: can you email me your skeleton / atlas files?
Would like to, but all I get when I click on your nick is PM, or MSNM/WLM, whatever that is.
alex.seeck
  • Postovi: 29

Mitch

I pm'd you

---

Resolution for this was that slots that don't have any visible attachments cannot be used as seperators because it never reaches that part of the code.
Avatar
Mitch

Mitch
  • Postovi: 978

alex.seeck

Ok, thanks to Mitch it now works all well,

recap:

OLD runtime under Unity 5:

- rename any slot with a preceding *
- the slots must have attachments
- Add Skeleton Utility and click Spawn Submeshes
- the asterisked slots will be the first in the split off meshes, generated as Child GameObjects of the SkeletonAnimation GameObject
- In SkeletonUtilitySubmeshRenderer comment line 92 and 93 (setting LayerID is not working)
- Use the script from this post to show them for MeshRenderers ( Plugin to sort Spine with SpriteRenderer's layer)

NEW Runtime under Unity 5:

- Unfold Advanced of SkeletonAnimation and add as many items to the Submesh Separators as needed
- RELOAD the Skeleton Data Asset
- Add Skeleton Utility and click Spawn Submeshes
- the chosen slots will be the first in the split off meshes, generated as Child GameObjects of the SkeletonAnimation GameObject
- change their Sorting and Ordering directly

Hope this helps anyone

P.S.: For adding a new configuration (lets say from 2 to 3 submeshes) do the following:
- Delete the old submeshes
- Add as many new Submesh Separators to SkeletonAnimation as you need
- ENABLE the MeshRenderer component
- RELOAD the Skeleton Data Asset
- Spawn the submeshes
alex.seeck
  • Postovi: 29

decoamorim

alex.seeck je napisao/la:NEW Runtime under Unity 5:

- Unfold Advanced of SkeletonAnimation and add as many items to the Submesh Separators as needed
- RELOAD the Skeleton Data Asset
- Add Skeleton Utility and click Spawn Submeshes
- the chosen slots will be the first in the split off meshes, generated as Child GameObjects of the SkeletonAnimation GameObject
- change their Sorting and Ordering directly

Hope this helps anyone

P.S.: For adding a new configuration (lets say from 2 to 3 submeshes) do the following:
- Delete the old submeshes
- Add as many new Submesh Separators to SkeletonAnimation as you need
- ENABLE the MeshRenderer component
- RELOAD the Skeleton Data Asset
- Spawn the submeshes
Perfect! Thanks!
Developer/Founder at DCF Studios
http://www.studiosdcf.com/
Author of
Cruz Brothers[PS4 / STEAM] [upcoming on XboxOne] - http://www.cruzbrothersgame.com
Bunny Battle Arena[STEAM] - https://store.steampowered.com/app/872340/Bunny_Battle_Arena/
Avatar
decoamorim
  • Postovi: 131


Natrag na Unity