// Update is called once per frame void Update() { if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.Dead) { return; } if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.Vanilla) { GolfBallCamera.SetActive(false); OverWorldCamera.SetActive(false); GolfBallCamera2.SetActive(false); Vector3 actualPlayerPosition = actualPlayer.transform.position; Vector3 eye = actualPlayer.transform.position - actualPlayer.transform.forward * -100.0f + actualPlayer.transform.up * +25.0f; Vector3 cameraForward = actualPlayer.transform.position - eye; cameraForward.Normalize(); Vector3 cameraLeft = Vector3.Cross(actualPlayer.transform.up, cameraForward).normalized; Vector3 cameraUp = Vector3.Cross(cameraForward, cameraLeft).normalized; transform.position = Vector3.MoveTowards(transform.position, VanillaCameraFollow.transform.position, 50.0f * Time.deltaTime); transform.LookAt(eye, cameraUp); //Camera FOV if (currentFOV != VanillaFOV) { if (currentFOV < VanillaFOV) { GetComponent <Camera>().fieldOfView = currentFOV + 1.0f; currentFOV = GetComponent <Camera>().fieldOfView; } else { GetComponent <Camera>().fieldOfView = currentFOV - 1.0f; currentFOV = GetComponent <Camera>().fieldOfView; } } } else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.Weapon) { Vector3 actualPlayerPosition = actualPlayer.transform.position; Vector3 eye = actualPlayer.transform.position - actualPlayer.transform.forward * -100.0f + actualPlayer.transform.up * +25.0f; Vector3 cameraForward = actualPlayer.transform.position - eye; cameraForward.Normalize(); Vector3 cameraLeft = Vector3.Cross(actualPlayer.transform.up, cameraForward).normalized; Vector3 cameraUp = Vector3.Cross(cameraForward, cameraLeft).normalized; transform.position = Vector3.MoveTowards(transform.position, WeaponCameraFollow.transform.position, 50.0f * Time.deltaTime); transform.LookAt(eye, cameraUp); //Camera FOV if (currentFOV < WeaponFOV) { //currentFOV = currentFOV + 1.0f; GetComponent <Camera>().fieldOfView = currentFOV + 1.0f; currentFOV = GetComponent <Camera>().fieldOfView; } /*Vector3 actualPlayerPosition = actualPlayer.transform.position; * actualPlayerPosition.x = actualPlayerPosition.x + 0.5f; * actualPlayerPosition.y = actualPlayerPosition.y + 3.0f; * actualPlayerPosition.z = actualPlayerPosition.z + 4.0f; * transform.position = Vector3.MoveTowards(transform.position, actualPlayerPosition, 75.0f * Time.deltaTime); * * //Camera Movement * float x = Input.GetAxis("CameraHorizontal") * Time.deltaTime * 35.0f; * float y = Input.GetAxis("CameraVertical") * Time.deltaTime * 35.0f; * transform.Rotate(y * 2.0f, x * 2.0f, 0);*/ } else if ((playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.GolfingOutsideRing) || (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.GolfingInsideRing)) { if (currentFOV > GolfClubFOV) { GetComponent <Camera>().fieldOfView = currentFOV - 1.0f; currentFOV = GetComponent <Camera>().fieldOfView; } Vector3 actualPlayerPosition = actualPlayer.transform.position; Vector3 eye = actualPlayer.transform.position - actualPlayer.transform.forward * -100.0f + actualPlayer.transform.up * -10.0f; Vector3 cameraForward = actualPlayer.transform.position - eye; cameraForward.Normalize(); Vector3 cameraLeft = Vector3.Cross(actualPlayer.transform.up, cameraForward).normalized; Vector3 cameraUp = Vector3.Cross(cameraForward, cameraLeft).normalized; transform.position = Vector3.MoveTowards(transform.position, GolfingCameraFollow.transform.position, 50.0f * Time.deltaTime); if ((horAndVertCameraMoving == false) && (horAndVertCameraMoved == false)) { transform.LookAt(eye, cameraUp); } if ((horAndVertCameraMoving == false) && (horAndVertCameraMoved == true)) { //Quaternion rotation = Quaternion.LookRotation(actualPlayer.transform.position - transform.position); //transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime); //transform.rotation = Quaternion.Slerp } float x = Input.GetAxis("CameraHorizontal") * Time.deltaTime * 35.0f; if (x != 0.0f) { previousX = x; horAndVertCameraMoving = true; transform.Rotate(0, x * 1.0f, 0); } if ((x == 0.0f) && (previousX != 0.0f)) { horAndVertCameraMoving = false; horAndVertCameraMoving = true; } if ((x == 0.0f) && previousX == 0.0f) { horAndVertCameraMoving = false; horAndVertCameraMoved = false; } //print(x); //float y = Input.GetAxis("CameraVertical") * Time.deltaTime * 35.0f; //transform.Rotate(y * 0.5f, x * 0.5f, 0); } else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.BallFlying) { if (playerManagerScript.ReturnGolfBallHasStruckTerrain() == true) { GolfBallCamera2.SetActive(true); Vector3 pos = actualGolfBall.transform.position; pos.z -= 5.0f; pos.y += 50.0f; GolfBallCamera2.transform.position = pos; GolfBallCamera2.transform.RotateAround(actualGolfBall.transform.position, -Vector3.up, 32.0f * Time.deltaTime); GolfBallCamera.SetActive(false); } else { if (playerManagerScript.ShowCurrentClub() != Player_Manager.CurrentClub.Putter) { GolfBallCamera2.SetActive(false); GolfBallCamera.SetActive(true); } else { transform.position = Vector3.MoveTowards(transform.position, actualGolfBall.transform.position, 100.0f * Time.deltaTime); } } } else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.BirdsEye) { OverWorldCamera.SetActive(true); } }