We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
当下遇到一个问题,通过记录位置差值(PositionOffset)和旋转差值(RotationOffset),通过当前位置和旋转,计算出新的位置和旋转
差值通过另一个 GameObject(Target) 的位置和旋转与当前 GameObject(Self) 计算得出
位置差值:
PositionOffset = Self.transform.worldToLocalMatrix * (Target.transform.position - Self.transform.position);
旋转差值:
RotationOffset = Quaternion.Inverse(Self.transform.rotation) * Target.transform.rotation; // 四元数差值
位置:
Self.transform.position + PositionOffset;
旋转:
Self.transform.rotation * RotationOffset;
https://stackoverflow.com/questions/50428971/unity3d-relative-offset-object-rotation-using-quaternions
The text was updated successfully, but these errors were encountered:
No branches or pull requests
[Unity] 如何记录位置和旋转变化前后的差值及还原
背景介绍
当下遇到一个问题,通过记录位置差值(PositionOffset)和旋转差值(RotationOffset),通过当前位置和旋转,计算出新的位置和旋转
差值通过另一个 GameObject(Target) 的位置和旋转与当前 GameObject(Self) 计算得出
解决方案
记录
位置差值:
旋转差值:
还原
位置:
旋转:
参考链接
https://stackoverflow.com/questions/50428971/unity3d-relative-offset-object-rotation-using-quaternions
The text was updated successfully, but these errors were encountered: