Hello devs, amazing work on this asset.
I have a question, I got your asset to work on something.
I want to make a game similar to this:
but I want the characters to be able to lose, gain, and even replace limbs
I was thinking of using sockets, and having separate object,
Or other ways.
Anyway, devs, How would you go about doing it? I was hoping to find bone-disconnect functionality, but if not, I think there are other ways and other compromise.
Any idea is appreciated.
Thank you.
Hi!
It took some time to prepare the answer.
We think the animation of the character's joints being separated is - a bit terrifying - but pretty cool!
Unfortunately, AnyPortrait makes it impossible for the bone structure to change during runtime.
It's a matter of the structure of the system, so it's impossible for us to embed that function.
Even so, it doesn't mean you can't achieve this cool effect.
As you said, you can implement the effect using Socket and external objects.
Of course, you can directly control the position of the bones using scripts.
The functions are introduced on the following page, but it may not provide the level you are looking for.
https://rainyrizzle.github.io/en/Script/SC_Bone.html
Instead, we reproduced the method you mentioned using Sockets and external objects.
The following example explains "How to implement an effect where a character's arms detach and fly away when a key on the keyboard is pressed".
( If the image looks small, you can click on it to enlarge it. )
This is the snowman character we prepared.
It simply consists of two arms, a hat, and a body.
We're going to implement this character's "Arm 1" to detach and fly away.
We made animations normally.
Nothing unusual so far.
We will activate the Socket so that an external image equal to "Arm 1" is attached.
(1) Select the mesh group and choose the Bone tab.
(2) Select the bone corresponding to Arm 1.
(3) Enable Socket.
Now Bake and go back to the Unity Editor.
Another image asset with the same appearance corresponding to the arm was prepared as above.
Since these images were imported as a "Sprite" type, we'll use a SpriteRenderer in the explanation below.
Now let's find the Socket and create an external "arm object" as its child.
(1) Select a character, and select "Root Unit > (Name of Root Mesh Group) > __Bone Group" in the Hierarchy tab.
Bones will be displayed, and find the GameObject corresponding to the Socket there. (It will probably have the letters "Socket" appended to its name.)
(2) Add an empty GameObject with Socket selected.
(1) We named the GameObject added as a child of Socket "ArmObject 1".
(2) Add a new GameObject as a child of "ArmObject 1". (We named it "Sprite".)
(3) Add "Sprite Renderer" component to "Sprite" GameObject, and set the prepared "arm image".
We've added an image, but it's probably not visible on the Scene screen.
It's because of Scale. If the Sprite object is equal to AnyPortrait's default scale, it will typically be scaled to 1/100. (Due to the AnyPortrait setting.)
(1) Select the "Sprite" GameObject.
(2) Change the Scale value to (100, 100, 100) or an appropriately large value.
(3) The arm image is now displayed according to the size of the AnyPortrait character.
Now we will adjust the position so that the arm image overlaps with AnyPortrait's arm and hides it.
(1) Select the "Sprite" GameObject. (Do not select the parent "ArmObject 1".)
(2) Adjust Position and Rotation to make (3) overlap with the original mesh.
It won't be too awkward if you don't make it completely overlap.
From here, it is an additional effect of our interest. :)
We will add a physics effect to the detached arm.
(1) Select the "Sprite" GameObject.
(2) Add the "Box Collider 2D" component.
(3) Modify the size of the collider to fit the image.
(1) And this time select its parent "ArmObject 1".
(2) Add a "Rigidbody 2D" object. (Body Type will be managed by script later, so it is recommended to set it to Dynamic and set physical properties.)
(Additionally, we added a SortingGroup for rendering order.)