AnyPortrait > Manual > Refer to a position using a Socket

Refer to a position using a Socket


1.0.0

Adding a knife to the character's hand or adding a particle effect to the head is common in other games.
In Unity, you can do this simply by adding it as a child of the GameObject in the Hierarchy.
Unfortunately, AnyPortrait's system does not follow Unity's Hierarchy calculation.
Since AnyPortrait's system uses an improved calculation formula, it is impossible to refer to the GameObject of the mesh.
(That's why AnyPortrait's the local coordinates of GameObjects always have 0, 0.)
Instead, a feature called Socket can solve this problem.
This page explains how to attach an external GameObject to a character using Socket.




Socket of meshes




(1) Select the Setting tab of the mesh group.
(2) Select the mesh to which you want to attach the socket.
(3) Press the Socket Disabled button on the right UI to change to Socket Enabled.




When you bake and go to the scene, you can see that a GameObject with the name "(mesh name) Socket" has been added to the selected mesh.
The socket is created and ready to attach another object.




I tried adding a Sphere object as a test.
The position is slightly upwards.




When you run the game, you can see the moving sphere above your head.




Socket of bones




(1) Select the Bone tab.
(2) Select the bone to set the socket.
(3) Press Socket Disabled button to make Socket Enabled status.




Bake and go back to the scene to check.
As in the case of meshes, a socket has been created with the name "(bone name) Socket".
I added particle effect this time.




When you start the game, you can see the effects of particles following the position of the bone.