I'm trying to do the following:
Have a rotation only (no transforms) with x,y,z.
Each rotation axis above respectfully having a minimal and maximum rotation angle with a current angle.
This will be for each bone of said character's skeleton, note the weights will be applied as per usual when doing animations, however there will be no animation data.
bones to rotation info, apply changes, info back to bones, apply changes, info back to bones...
Q: SetBones And GetBones, how would I get and set the bone data?
//imports...
public class BoneControllerClass : MonoBehaviour {
//used to modify the bone data struct for each bone (ediable via Unity Editor)
public BoneConstraintData[] BoneData;
//gets refs to bone data from character
public Bones[] GetBones(){ /*..Help..Here..*/ }
public BoneConstraintData[] SetBoneConstraints(BoneConstraintData[] _BoneData) { /*..CODE..HERE..*/}
public void SetBones(BoneConstraintData[] _BoneData){ /*..Help..Here..*/ }
public void Start(){
// generate bone data with zeros
BoneData = GetBones();
// set bone data constraints
BoneData = SetBoneConstraints(BoneData);
}
public void Update(){
// do something for smooth clamping, optionally this could be applied above as with Delta Time...
// CODE EXAMPLE HERE, optionally another function can be added...
BoneData[0].currentXAngle = 12.0f * Time.DeltaTime; //or BoneDataNew[0].currentXAngle = 12.0f;
// END CODE EXAMPLE HERE
// applies new bone rotation information, (note each bone carries the bone information of rotation like in IK Bone Logic...)
SetBones(BoneData);
}
}
//holds Min, Max, Current Angles And Bone Ref.
public class BoneConstraintData{
string bone_name;
float minXAngle, maxXAngle, currentXAngle;
float minYAngle, maxYAngle, currentYAngle;
float minZAngle, maxZAngle, currentZAngle;
}
I'm using version 5.x.x of Unity 3D.