public void ProcessAnimation(AnimationStream stream) { m_SlavedTransform.SetPosition(stream, m_BoneToFollow.GetPosition(stream)); m_SlavedTransform.SetRotation(stream, m_BoneToFollow.GetRotation(stream)); }
public void ProcessAnimation(AnimationStream stream) { if (!m_AimDirectionInitialized) { m_CurrentYaw = animState.aimYaw; m_CurrentPitch = animState.aimPitch; m_AimDirectionInitialized = true; } // TODO: (sunek) Get rid of stuttering var t = settings.stiffness * stream.deltaTime; m_CurrentYaw = Mathf.LerpAngle(m_CurrentYaw, animState.aimYaw, t); m_CurrentPitch = Mathf.LerpAngle(m_CurrentPitch, animState.aimPitch, t); var deltaYaw = Mathf.DeltaAngle(animState.aimYaw, m_CurrentYaw); var deltaPitch = Mathf.DeltaAngle(animState.aimPitch, m_CurrentPitch); var deltaRotation = Quaternion.Euler(new Vector3(-deltaPitch, deltaYaw, 0)); var angle = Quaternion.Angle(Quaternion.identity, deltaRotation); if (angle > settings.maxAngle) { t = settings.maxAngle / angle; m_CurrentYaw = Mathf.LerpAngle(animState.aimYaw, m_CurrentYaw, t); m_CurrentPitch = Mathf.LerpAngle(animState.aimPitch, m_CurrentPitch, t); deltaYaw = Mathf.DeltaAngle(animState.aimYaw, m_CurrentYaw); deltaPitch = Mathf.DeltaAngle(animState.aimPitch, m_CurrentPitch); deltaRotation = Quaternion.Euler(new Vector3(-deltaPitch, deltaYaw, 0)); } if (m_DragHistory.Count <= settings.rollDelay) { m_DragHistory.Enqueue(deltaRotation); } var drag = Quaternion.SlerpUnclamped(Quaternion.identity, deltaRotation, settings.dragWeight); var roll = m_DragHistory.Count < settings.rollDelay + 1 ? m_DragHistory.Peek() : m_DragHistory.Dequeue(); roll = Quaternion.SlerpUnclamped(Quaternion.identity, new Quaternion(0f, roll.y, 0f, roll.w), settings.rollWeight); var handPosition = m_Effectorhandle.GetPosition(stream); var handRotation = m_Effectorhandle.GetRotation(stream); var weaponPivotPosition = m_WeaponPivot.GetPosition(stream); var weaponPivotRotation = m_WeaponPivot.GetRotation(stream); var dragPivot = weaponPivotRotation * settings.dragPivot; var rollPivot = weaponPivotRotation * settings.rollPivot; var dragPivotDelta = handPosition - (weaponPivotPosition + dragPivot); var rollPivotDelta = handPosition - (weaponPivotPosition + rollPivot); var handOffset = drag * dragPivotDelta; handOffset = handOffset - dragPivotDelta; var rollOffset = roll * rollPivotDelta; rollOffset = rollOffset - rollPivotDelta; handPosition = handPosition + handOffset + rollOffset; handRotation = drag * handRotation * roll; m_WeaponHandResult.SetPosition(stream, handPosition); m_WeaponHandResult.SetRotation(stream, handRotation); }