mcplata

Hi All!

First of all sorry about my english ;) I had searched about this question topic and see that some related issues have some answers but...not really got how to...

We are developing a game, where user are able to create his character from a defined pack of parts. For example he can choose to put in to his character a Robot head, an animal head, an human head... and this will be the same for the rest of body parts (legs, chest, feet, etc)

The problem is how to define the skeleton data and json dinamically in order to allow the user to choose the parts and then generate the data and jason for the squeleton... Its this possible?

Thanks in advance for the help.
E.
mcplata
  • Mesajlar: 1

Pharan

(1) This isn't a Unity-specific question. I'll be moving this to the Editor forum soon so it can benfit other users. Let's open a new topic if something Unity-specific comes up. In any case, this question involves many smaller problems. Some of which may have already been answered.

(2) There are many possible solutions for what you want.
I can offer my answer, but I've never implemented something like this for production before so others who have actually made the whole pipeline work in their games may have better and more detailed answers.

In general, you have to add all the attachments to the skeleton. The robot head. The animal head. The skeleton head. Put them all in Spine in one skeleton. Animate normally.
And let the runtime handle changing the head, or the legs, etc. You can do this by dynamically generating a skin object for the skeleton to use (which stores what head or leg to use).
mcplata yazdı:The problem is how to define the skeleton data and json dinamically in order to allow the user to choose the parts and then generate the data and jason for the squeleton... Its this possible?
You seem to be preempting a solution of your own. This (regenerating a new json and reloading that) is not necessarily a good way to do it, but if you understand how Spine works and it makes sense to you with your understanding, go ahead.
Kullanıcı avatarı
Pharan
  • Mesajlar: 5366

zeuxgame

I just had this problem few days ago
you can use Unity Texture2D.SetPixel to generate a texture yourself
to doing this, you need the atlas
and analyze its xy and size(or use original part size)
when exporting, do not let rotation option checked

I can't find a way to generate texture like spine do
so you should let your part texture to be "alpha is transparent" checked
and origin sprite sheet change the option too
in this case if you use Spine's Skeleton shader
it will be rendered weirdly
so after asign a texture to origin material
and change to Sprite/Default
on runtime copy the origin material then SetTexture using the texture you had generated
and in the object that has skeletonanimation
change the material in meshrenderer every frame by using OnObjectRendered
and this will let character only has one texture and can change part by generate a full texture that has no repeat part on it

the short is it will be a little bit expensive when generate texture
but don't really mind it, it's not affect too much
zeuxgame
  • Mesajlar: 29

Pharan

Kullanıcı avatarı
Pharan
  • Mesajlar: 5366


Dön Unity