private Vector3 getNewPos(E_CamType type, PlayerData data) { if (type == E_CamType.CAM_3D_AIR) { return(Camera3DAirPos(data)); } else if (type == E_CamType.CAM_3D_GROUND) { return(Camera3DGroundPos(data)); } else if (type == E_CamType.CAM_3D_MOVING_BOX) { return(Camera3DMoveingBoxPos(data)); } return(Camera2DPos(data)); }
private Quaternion getNewRot(E_CamType type, PlayerData data) { if (type == E_CamType.CAM_3D_AIR) { return(Camera3DAirRot(data)); } else if (type == E_CamType.CAM_3D_GROUND) { //return Camera3DGroundRot(data); return(Camera3DAirRot(data)); } else if (type == E_CamType.CAM_3D_MOVING_BOX) { return(Camera3DMovingBoxRot(data)); } return(Camera2DRot(data)); }
void Start() { m_player = FindObjectOfType <PlayerStateMachine>(); Vector3 playerPos = m_player.gameObject.transform.position; gameObject.transform.position = new Vector3(playerPos.x, playerPos.y + 3.0f, -8.0f); m_transitionTimer = new Timer(); m_transitionTimer.m_time = 0.2f; if (m_player && m_player.m_data.m_use3D) { m_currentCam = E_CamType.CAM_3D_AIR; m_nextCam = E_CamType.CAM_3D_AIR; } else { m_currentCam = E_CamType.CAM_2D; m_nextCam = E_CamType.CAM_2D; } }
void LateUpdate() { // this is teh only player input that directly affects the camera system ///if (Input.GetButtonDown("ResetCamera")) ///{ /// m_verticalTilt = 0.0f; ///} /// ///m_verticalTilt += Input.GetAxis("Mouse Y") * Time.deltaTime * 60.0f; ///m_verticalTilt += Input.GetAxis("Right Stick Y") * Time.deltaTime * 60.0f * 2.0f; ///m_verticalTilt = Mathf.Clamp(m_verticalTilt, m_minVerticalTilt, m_maxVerticalTilt); if (Time.deltaTime > 0.0f) { float previousOffsetX = m_offsetX; float previousOffsetY = m_offsetY; m_offsetX = Input.GetAxisRaw("Right Stick X") * (Input.GetAxisRaw("Right Stick X") > 0 ? m_maxOffsetX : -m_minOffsetX); m_offsetY = Input.GetAxisRaw("Right Stick Y") * (Input.GetAxisRaw("Right Stick Y") > 0 ? m_maxOffsetY : -m_minOffsetY); if (m_offsetX > previousOffsetX + m_offsetXMovmentSpeed) { m_offsetX = previousOffsetX + m_offsetXMovmentSpeed; } else if (m_offsetX < previousOffsetX - m_offsetXMovmentSpeed) { m_offsetX = previousOffsetX - m_offsetXMovmentSpeed; } if (m_offsetY > previousOffsetY + m_offsetYMovmentSpeed) { m_offsetY = previousOffsetY + m_offsetYMovmentSpeed; } else if (m_offsetY < previousOffsetY - m_offsetYMovmentSpeed) { m_offsetY = previousOffsetY - m_offsetYMovmentSpeed; } } // makes all movments relative to the charicter the player is controling PlayerData followData = m_player.getFollowData(); if (!followData.m_use3D) { m_nextCam = E_CamType.CAM_2D; } else { if (followData.GetVelocity().y != -9.81f) { m_nextCam = E_CamType.CAM_3D_AIR; } else if (followData.m_moveingBox) { m_nextCam = E_CamType.CAM_3D_MOVING_BOX; } else { m_nextCam = E_CamType.CAM_3D_GROUND; } } m_transitionTimer.Cycle(); if (m_currentCam != m_nextCam) { if (!m_transitionTimer.m_playing) { m_transitionTimer.Play(); } gameObject.transform.rotation = Quaternion.Slerp(getNewRot(m_currentCam, followData), getNewRot(m_nextCam, followData), m_transitionTimer.GetLerp()); gameObject.transform.position = Vector3.Lerp(getNewPos(m_currentCam, followData), getNewPos(m_nextCam, followData), m_transitionTimer.GetLerp()); if (m_transitionTimer.m_completed) { m_currentCam = m_nextCam; m_transitionTimer.Stop(); } } else { m_transitionTimer.Stop(); ///if (m_currentCam == E_CamType.CAM_2D) ///{ /// m_verticalTilt = 0.0f; ///} gameObject.transform.rotation = getNewRot(m_currentCam, followData); gameObject.transform.position = getNewPos(m_currentCam, followData); } }