public static void LookAt(Transform origin, Transform target, Vector3 worldUp = default(Vector3), float lenght = 5) { if (!origin || !target) { return; } worldUp = worldUp == default(Vector3) ? Vector3.up : worldUp; Vector3 originV = origin.position; Vector3 forwardDirection = target.position - originV; GizmosForQuaternion.LookRotation(originV, forwardDirection, worldUp, lenght); }
public static void LookAt(Transform origin, Vector3 worldPosition, Vector3 worldUp = default(Vector3), float lenght = 5) { if (!origin) { return; } worldUp = worldUp == default(Vector3) ? Vector3.up : worldUp; Vector3 originV = origin.position; Vector3 forwardDirection = worldPosition - originV; GizmosForQuaternion.LookRotation(originV, forwardDirection, worldUp, lenght); GizmosForVector.ShowVectorValue(worldPosition, "worldPosition", worldPosition, Color.red); Color temp = Gizmos.color; Gizmos.color = Color.red; Gizmos.DrawSphere(worldPosition, 0.2f); Gizmos.color = temp; }