// Use this for initialization void Awake() { this.transform.position = StartingWaypoint.transform.position; m_CurrentWaypoint = StartingWaypoint; m_RailCartActivated = false; m_RailCartFinished = false; m_HasEndedRail = false; m_MaxVelocity = MaxSpeed; mainCameraOrth = Camera.main.orthographicSize; }
// Update is called once per frame void Update() { HandleReturningCameraSize (); if (m_RailCartActivated == true && m_RailCartFinished == false) { m_PlayerObject.GetComponent<PlayerController>().DisableControls(); HandleCameraAssignment(); m_PlayerObject.transform.position = this.transform.position; if (m_Velocity < m_MaxVelocity) { m_Velocity += 10.0f * Time.deltaTime; } else if (m_Velocity > m_MaxVelocity) { m_Velocity -= 10.0f * Time.deltaTime; } Vector3 position = this.transform.position; position = Vector3.MoveTowards(this.transform.position, m_CurrentWaypoint.transform.position, m_Velocity * Time.deltaTime ); this.transform.position = position; if(this.transform.position == m_CurrentWaypoint.transform.position) { if (m_CurrentWaypoint.IsFinalWaypoint == false) { m_CurrentWaypoint = m_CurrentWaypoint.ChildWaypoint; } else if( m_CurrentWaypoint.IsFinalWaypoint == true ) { m_RailCartFinished = true; m_CurrentWaypoint = StartingWaypoint; this.transform.position = StartingWaypoint.transform.position; cameraPoint.target = m_PlayerObject.transform; m_HasEndedRail = true; m_PlayerObject.GetComponent<PlayerController>().EnableControls(); } } } }