// Use this for initialization void Start() { //Ensure a networkView exists if (GetComponent <NetworkView>() != null) { //Ensure that initialization only executes if this is a valid instance. if (GetComponent <NetworkView>().isMine || Network.peerType == NetworkPeerType.Disconnected) { camera = GameObject.FindGameObjectWithTag(GameTag.PlayerCamera).transform; player = this.transform; //Create an object at runtime for the camera to look at. cameraTargetObject = new CameraTargetObject(); cameraTargetObject.Init("Camera Target", new Vector3(0f, 1f, 0f), new GameObject().transform, player.transform); // Create an empty object at runtime for the camera to look at. cameraMountPoint = new CameraMountPoint(); cameraMountPoint.Init("Camera Mount", cameraNormalPos, new GameObject().transform, cameraTargetObject.XForm); camera.parent = cameraTargetObject.XForm.parent; } else { enabled = false; } } }
// Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag(GameTag.Player); cam = GameObject.Find("Camera"); follow = new CameraTargetObject(); follow.Init("Camera Target", new Vector3(0f, yOffset, zOffset), new GameObject().transform, player.transform); PlayerMotor pm = player.GetComponent <PlayerMotor>(); pm.OnNormalMode += NormalMode; pm.OnTargetMode += TargetMode; pm.OnAcquireTarget += NewTarget; pm.OnSprintMode += SprintMode; //Hide cursor if build #if UNITY_EDITOR Cursor.visible = true; #else Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; #endif }