Last active
April 16, 2018 07:55
-
-
Save todorok1/6ee68df3d5c6ecee01f689dd7fb733a9 to your computer and use it in GitHub Desktop.
Unityチュートリアル・カメラの追従とズームイン・ズームアウトさせるスクリプト。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vector3 GetMagnifiedOffset(){ | |
// 規格化されたオフセットを取得 | |
Vector3 normalizedOffset = offset.normalized; | |
// 『Sphere』オブジェクトとカメラの距離を取得 | |
float offsetDistance = offset.magnitude; | |
// offsetDistanceに拡大率をかけて補正後の距離を取得 | |
float magnifiedDistance = offsetDistance * (200f - magnify) / 100f; | |
// 規格化されたベクトルと拡大後の距離からオフセットを返す | |
Vector3 magnifiedOffset = magnifiedDistance * normalizedOffset; | |
return magnifiedOffset; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment