void SaveTransformValues() { Vector3 localPosition = mTargetTransform.localPosition; mDampingX.Reset(localPosition.x, 0, localPosition.x); mDampingY.Reset(localPosition.y, 0, localPosition.y); mDampingPitch.Reset(mPitch, 0, mPitch); mDampingYaw.Reset(mYaw, 0, mYaw); mDampingScale.Reset(mScale, 0, mScale); }
public void MotionTo(Vector3 targetPos, float pitch, float yaw, float scale, float overshoot, float friction) { pitch = mPitch + MathUtil.ReduceAngle(pitch - mPitch); yaw = mYaw + MathUtil.ReduceAngle(yaw - mYaw); //Debug.Log("MotionTo: " + mPitch + " -> " + pitch + " yaw:" + mYaw + " -> " + yaw); //Debug.Log("curPitch=" + mDampingPitch.Value + " curYaw=" + mDampingYaw.Value); mDampingX.Target = targetPos.x; mDampingY.Target = targetPos.y; mDampingPitch.Target = pitch; //注意mDampingYaw的当前value可能是超过360度,而mYaw的值是规约后的,重置一下避免多转一圈的情况 mDampingYaw.Reset(mYaw, mDampingYaw.Velocity, yaw); mDampingScale.Target = scale; foreach (Damping damping in mTransformDampings) { damping.SetFriction(overshoot, friction); } mInMotion = true; }