//Actually hits the golf ball by predesignated levels of power as well as the player's swingPower public void HitGolfBall(float swingPower) { if (playerManagerScript.ShowCurrentClub() == Player_Manager.CurrentClub.Driver) { Vector3 actualPlayerDirection = actualPlayer.transform.forward; actualPlayerDirection = actualPlayerDirection + new Vector3(0, 1, 0); GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; GetComponent <Rigidbody>().AddForce((300.0f * swingPower) * actualPlayerDirection); BallInAir = true; } else if (playerManagerScript.ShowCurrentClub() == Player_Manager.CurrentClub.Iron) { Vector3 actualPlayerDirection = actualPlayer.transform.forward; actualPlayerDirection = actualPlayerDirection + new Vector3(0, 1, 0); GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; GetComponent <Rigidbody>().AddForce((200.0f * swingPower) * actualPlayerDirection); BallInAir = true; } else if (playerManagerScript.ShowCurrentClub() == Player_Manager.CurrentClub.Putter) { Vector3 actualPlayerDirection = actualPlayer.transform.forward; actualPlayerDirection = actualPlayerDirection + new Vector3(0, 0, 0); GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; GetComponent <Rigidbody>().AddForce((200.0f * swingPower) * actualPlayerDirection); BallIsPutting = true; } }
// Update is called once per frame void Update() { /*if (!isLocalPlayer) * { * return; * }*/ if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.Dead) { return; } if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.Vanilla) { if (goBackToRotation == true) { goBackToRotation = false; Quaternion newRotationValue = new Quaternion(0, 0, 0, 0); newRotationValue.Set(originalRotationValue.x, transform.rotation.y, originalRotationValue.x, originalRotationValue.w); transform.rotation = Quaternion.Slerp(transform.rotation, newRotationValue, Time.time * 1.0f); } float x = Input.GetAxis("Horizontal") * Time.deltaTime * 35.0f; float y = Input.GetAxis("Vertical") * Time.deltaTime * 35.0f; transform.Translate(0, 0, y); transform.Translate(x * 2.0f, 0, 0); float z = Input.GetAxis("CameraHorizontal") * Time.deltaTime * 35.0f; transform.Rotate(0, z * 4.0f, 0); } else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.Weapon) { goBackToRotation = true; float x = Input.GetAxis("Horizontal") * Time.deltaTime * 35.0f; float y = Input.GetAxis("Vertical") * Time.deltaTime * 35.0f; transform.Translate(x, 0, y); //this needs to rotate through the values so that if you are facing forward it is not as senstive as turning around quickly float z = Input.GetAxis("CameraHorizontal") * Time.deltaTime * 35.0f; float h = Input.GetAxis("CameraVertical") * Time.deltaTime * 35.0f; transform.Rotate(h, z * 7.0f, 0); } else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.GolfingOutsideRing) { float x = Input.GetAxis("Horizontal") * Time.deltaTime * 35.0f; float y = Input.GetAxis("Vertical") * Time.deltaTime * 35.0f; transform.Translate(0, 0, y); transform.Rotate(0, x * 6.0f, 0); } else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.GolfingInsideRing) { //??? float x = Input.GetAxis("Horizontal") * Time.deltaTime * 35.0f; float y = Input.GetAxis("Vertical") * Time.deltaTime * 35.0f; transform.Translate(0, 0, y); transform.Rotate(0, x * 6.0f, 0); //transform.RotateAround(actualGolfBall.transform.position, Vector3.up, speed * Time.deltaTime); } else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.BallFlying) { if (playerManagerScript.ShowCurrentClub() == Player_Manager.CurrentClub.Putter) { float x = Input.GetAxis("Horizontal") * Time.deltaTime * 10.0f; //float y = Input.GetAxis("Vertical") * Time.deltaTime * 10.0f; //actualGolfBall.transform.Translate(0, 0, y); //actualGolfBall.transform.Translate(0, 0, x * 10.0f); //actualGolfBall.transform.Rotate(x * 10.0f, 0, 0); } else { //REMEMBER HOW TO RESEARCH TO MAKE THE GAME FEEL LIKE IT IS IN SLOW MOTION LIKE HEAVENLY SWORD float x = Input.GetAxis("Horizontal") * Time.deltaTime * 35.0f; float y = Input.GetAxis("Vertical") * Time.deltaTime * 35.0f; actualGolfBall.transform.Translate(x, 0, y); actualGolfBall.transform.Rotate(0, x * 2.0f, 0); } } else if (playerManagerScript.ShowCurrentPlayerState() == Player_Manager.PlayerStatus.BirdsEye) { } }
// 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); } }