// // void Start() { rotateTransform = rotateTransform == null ? transform : rotateTransform; creature = creature == null ? GetComponentInChildren<Creature>() : creature; if (Application.platform == RuntimePlatform.OSXWebPlayer || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXDashboardPlayer) macMouseFactor = 0.18f; // if (camTransform != null) { smoothCam = new GameObject("CAMDUMMY").transform; smoothCam.position = camTransform.position; // + Vector3.up; smoothCam.rotation = camTransform.rotation; smoothCam.parent = camTransform.parent; camTransform.parent = null; } }
// // void Start() { rotateTransform = rotateTransform == null ? transform : rotateTransform; creature = creature == null ? GetComponentInChildren<Creature>() : creature; #if UNITY_WEBPLAYER if (Application.platform == RuntimePlatform.OSXWebPlayer) { #else if (Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXDashboardPlayer) #endif macMouseFactor = 0.18f; // if (camTransform != null) { smoothCam = new GameObject("CAMDUMMY").transform; smoothCam.position = camTransform.position; // + Vector3.up; smoothCam.rotation = camTransform.rotation; smoothCam.parent = camTransform.parent; camTransform.parent = null; } } void Update() { // move creature.xFactor = Input.GetAxis("Horizontal"); creature.zFactor = Input.GetAxis("Vertical"); // jump if (Input.GetButtonDown("Jump")) creature.Jump(); // look if ((Application.isEditor || needRightPressed) && Input.GetMouseButton(1)) { #if UNITY_5 if (Cursor.visible) { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; } #else Screen.lockCursor = true; #endif rotateTransform.Rotate(rotateTransform.up, Input.GetAxis("Mouse X") * yawRotSpeed * macMouseFactor * mouseSensitivity, Space.World); pitch += Input.GetAxis("Mouse Y") * -pitchRotSpeed * macMouseFactor * mouseSensitivity * 1.1f; pitch = Mathf.Clamp(pitch, pitchMin, pitchMax); if (smoothCam != null) smoothCam.localEulerAngles = new Vector3(pitch, 0f, 0f); } else { #if UNITY_5 if (!Cursor.visible) { Cursor.visible = true; Cursor.lockState = CursorLockMode.None; } #else Screen.lockCursor = false; #endif } if (camTransform != null) { camTransform.position = smoothCam.position; camTransform.rotation = Quaternion.Slerp(camTransform.rotation, smoothCam.rotation, smoothness); } } void OnDestroy() { #if UNITY_5 Cursor.visible = true; Cursor.lockState = CursorLockMode.None; #else Screen.lockCursor = false; #endif } }