private void UpdateChildRotation() { FPMatrix matrix = FPMatrix.CreateFromQuaternion(_rotation); foreach (FPTransform child in tsChildren) { child.localRotation = FPQuaternion.CreateFromMatrix(FPMatrix.Inverse(matrix)) * _rotation; child.localPosition = FPVector.Transform(child.localPosition, FPMatrix.CreateFromQuaternion(child.localRotation)); child.position = TransformPoint(child.localPosition); } }
private void UpdatePlayMode() { if (tsParent != null) { _localPosition = tsParent.InverseTransformPoint(position); FPMatrix matrix = FPMatrix.CreateFromQuaternion(tsParent.rotation); _localRotation = FPQuaternion.CreateFromMatrix(FPMatrix.Inverse(matrix)) * rotation; } else { _localPosition = position; _localRotation = rotation; } if (rb != null) { if (rb.interpolation == FPRigidBody.InterpolateMode.Interpolate) { transform.position = Vector3.Lerp(transform.position, position.ToVector(), Time.deltaTime * DELTA_TIME_FACTOR); transform.rotation = Quaternion.Lerp(transform.rotation, rotation.ToQuaternion(), Time.deltaTime * DELTA_TIME_FACTOR); transform.localScale = Vector3.Lerp(transform.localScale, localScale.ToVector(), Time.deltaTime * DELTA_TIME_FACTOR); return; } else if (rb.interpolation == FPRigidBody.InterpolateMode.Extrapolate) { transform.position = (position + rb.FPCollider.Body.FPLinearVelocity * Time.deltaTime * DELTA_TIME_FACTOR).ToVector(); transform.rotation = Quaternion.Lerp(transform.rotation, rotation.ToQuaternion(), Time.deltaTime * DELTA_TIME_FACTOR); transform.localScale = Vector3.Lerp(transform.localScale, localScale.ToVector(), Time.deltaTime * DELTA_TIME_FACTOR); return; } } transform.position = position.ToVector(); transform.rotation = rotation.ToQuaternion(); transform.localScale = localScale.ToVector(); _scale = transform.lossyScale.ToFPVector(); }