AnyPortrait > Script > Bone
Functions that reference or control bones.
Contains functions that reference a socket or control it with IK.
Find the bone by name and return it.
If you do not specify a root unit index, first perform a full search from the root unit that is currently being rendered.
int rootUnitIndex : Root Unit Index (If not, search all)
string boneName : Name of the bone to reference
apOptBone : The bone retrieved. Return null if not
References socket of a bone.
Please refer to related page about socket.
apOptBone optBone : Bone containing socket
int rootUnitIndex : Root Unit Index (If not, search all)
string boneName : Name of the bone to reference
Transform : Socket Transform of bone. Return null if not
Controls the position of the bone.
You can interpolate using weights
IK does not work.
apOptBone optBone : Bone to control
int rootUnitIndex : Root Unit Index (If not, search all)
string boneName : Name of the bone to control
Vector3 position : Position to move
Space space : World refers to the coordinate system of the scene, and Self refers to the coordinate system of apPortrait.
float weight : Interpolation weight with position of animated bone
bool : If it refers to a bone that does not exist, false is returned.
Controls the rotation angle of the bone.
You can interpolate using weights.
apOptBone optBone : Bone to control
int rootUnitIndex : Root Unit Index (If not, search all)
string boneName : Name of the bone to control
float angle : Angle to rotate (Degree)
Space space : World refers to the coordinate system of the scene, and Self refers to the coordinate system of apPortrait.
float weight : Interpolation weight with rotation of animated bone
bool : If it refers to a bone that does not exist, false is returned.
Controls the size of the bone.
You can interpolate using weights.
apOptBone optBone : Bone to control
int rootUnitIndex : Root Unit Index (If not, search all)
string boneName : Name of the bone to control
Vector3 scale : Scale value
Space space : World refers to the coordinate system of the scene, and Self refers to the coordinate system of apPortrait.
float weight : Interpolation weight with scale of animated bone
bool : If it refers to a bone that does not exist, false is returned.
Use IK to move the bone.
Refer to the related page for how to set the IK of the bone.
You can interpolate using weights.
apOptBone optBone : Bone to control
int rootUnitIndex : Root Unit Index (If not, search all)
string boneName : Name of the bone to control
Vector3 position : Position to move. Depending on the IK, the location may not be reached.
Space space : World refers to the coordinate system of the scene, and Self refers to the coordinate system of apPortrait.
float weight : Interpolation weight with position of animated bone
bool isContiuous : If true, the IK result of the previous frame is referenced to ensure a natural result.
bool : If it refers to a bone that does not exist, false is returned.
Similar to the IK method, rotate the bone to view the requested position.
Unlike SetBoneIK (), it rotates one bone.
IK setting is not affected.
apOptBone optBone : Bone to control
int rootUnitIndex : Root Unit Index (If not, search all)
string boneName : Name of the bone to control
Vector3 position : Position to look at
Space space : World refers to the coordinate system of the scene, and Self refers to the coordinate system of apPortrait.
float weight : Interpolation weight with rotation value of animated bone
bool : If it refers to a bone that does not exist, false is returned.
Limit the position of the bone.
You can set the range for each axis.
You need to call a new one for each update, and you can make duplicate calls with different ConstraintBound types.
apOptBone optBone : Target Bone
int rootUnitIndex : Root Unit Index (If not, search all)
string boneName : Name of the target bone
float positionValue : The value of the position you want to restrict
ConstraintBound constraintBound : It has a type of "Min, Max, Preferred" for the X and Y axes, respectively.
Space space : World refers to the coordinate system of the scene, and Self refers to the coordinate system of apPortrait.
bool : If it refers to a bone that does not exist, false is returned.
If you set the default surface position for the X and Y axes, and input the current surface position, the position of the bone is corrected by the difference.
Specify the minimum and maximum ranges to ensure stable position correction.
Since it does not control the bones directly, it has the effect of preserving the animations created with FK.
apOptBone optBone : Bone to control
int rootUnitIndex : Root Unit Index (If not, search all)
string boneName : Name of the bone to control
float defaultSurfacePosition : The default surface position should be a generally constant value.
float currentSurfacePosition : Position of current surface
float minSurfacePosition : Minimum value of surface position
float maxSurfacePosition : Maximum value of surface position
ConstraintSurface constraintSurface : The axis of the surface (X, Y)
Space space : World refers to the coordinate system of the scene, and Self refers to the coordinate system of apPortrait.
bool : If it refers to a bone that does not exist, false is returned.
using UnityEngine;
using AnyPortrait;
public class BoneTest : MonoBehaviour
{
public apPortrait portrait;
void Start () { }
void Update ()
{
if(Input.GetMouseButtonDown(0))
{
Vector3 touchPosWorld = Camera.main.ScreenToWorldPoint(
new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
portrait.SetBoneIK(0, "Bone Hand R", touchPosWorld, Space.World, 1.0f, true);
}
}
}