PosAndRotExtensions Class |
Namespace: KSPDev.Extensions
The PosAndRotExtensions type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() ![]() | InverseTransformPosAndRot |
Transforms a pos&rot object from the world space to the local space. The opposite to
TransformPosAndRot(Transform, PosAndRot).
|
![]() ![]() | SetPosAndRot | Sets position and rotation in one call./// |
![]() ![]() ![]() | TransformPosAndRot |
Transforms a pos&rot object from the local space to the world space. The opposite to
InverseTransformPosAndRot(Transform, PosAndRot).
|
public static void ToLocal() { var parent = new GameObject(); parent.transform.position = Vector3.one; parent.transform.rotation = Quaternion.LookRotation(Vector3.up); var pr = new PosAndRot(Vector3.one, new Vector3(90, 0, 0)); Debug.LogFormat("Local: {0}", parent.transform.InverseTransformPosAndRot(pr)); Debug.LogFormat("World: {0}", pr); }
public static void ToWorld() { var parent = new GameObject(); parent.transform.position = Vector3.one; parent.transform.rotation = Quaternion.LookRotation(Vector3.up); var pr = new PosAndRot(); Debug.LogFormat("Local: {0}", pr); Debug.LogFormat("World: {0}", parent.transform.TransformPosAndRot(pr)); }