Please see the URL below. http://www015.upp.so-net.ne.jp/kira-kira/recording_sample.html
Click "Record" button, and click or drag on the screen. Then, click "stop" button.
click "play" button to see your replay.
In this sample, the position is recorded correctly, but the rotation is not. I dont know what is wrong with my code.
Help me please...
the code is like below.
function startRec() {
posXCurve = new AnimationCurve();
posZCurve = new AnimationCurve();
rotXCurve = new AnimationCurve();
rotYCurve = new AnimationCurve();
rotZCurve = new AnimationCurve();
rotX2Curve = new AnimationCurve();
rotY2Curve = new AnimationCurve();
rotZ2Curve = new AnimationCurve();
recStart = true;
isRecording = true;
}
function stopRec() {
print("STOPPED!!");
isRecording = false;
clip1.SetCurve("", Transform, "localPosition.x", posXCurve);
clip1.SetCurve("", Transform, "localPosition,z", posZCurve);
clip1.SetCurve("", Transform, "localRotation,x", rotXCurve);
clip1.SetCurve("", Transform, "localRotation,y", rotYCurve);
clip1.SetCurve("", Transform, "localRotation,z", rotZCurve);
clip1.SetCurve("_d_camera", Transform, "localRotation,x", rotX2Curve);
clip1.SetCurve("_d_camera", Transform, "localRotation,y", rotY2Curve);
clip1.SetCurve("_d_camera", Transform, "localRotation,z", rotZ2Curve);
obj.animation.AddClip (clip1, "aniMo");
}
function playAnim() {
obj.animation.Play("aniMo");
}
function FixedUpdate () {
if(recStart) {
nowTime = 0;
recStart = false;
}
if(isRecording){
posXCurve.AddKey(nowTime, mainObj.transform.localPosition.x);
posZCurve.AddKey(nowTime, mainObj.transform.localPosition.z);
rotXCurve.AddKey(nowTime, hRotObj.transform.localEulerAngles.x);
rotYCurve.AddKey(nowTime, hRotObj.transform.localEulerAngles.y);
rotZCurve.AddKey(nowTime, hRotObj.transform.localEulerAngles.z);
rotX2Curve.AddKey(nowTime, vRotObj.transform.localEulerAngles.x);
rotY2Curve.AddKey(nowTime, vRotObj.transform.localEulerAngles.y);
rotZ2Curve.AddKey(nowTime, vRotObj.transform.localEulerAngles.z);
nowTime = nowTime + Time.deltaTime;
}
}