Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBenjamin Schulz Enokian
12,393 PointsCamera doesn't follow Frog anymore.
I receive the same error about many times saying: rc.right == m_GfxWindow->GetWidth() && rc.bottom == m_GfxWindow->GetHeight() followed by: SUCCEEDED(hr)
Benjamin Schulz Enokian
12,393 Pointsusing System.Collections; using UnityEngine.UI; using UnityEngine.SceneManagement;
public class GameState : MonoBehaviour {
private bool gameStarted = false;
[SerializeField]
private Text gameStateText;
[SerializeField]
private GameObject player;
[SerializeField]
private BirdMovement birdMovement;
[SerializeField]
private FollowCamera followCamera;
private float restartDelay = 3f;
private float restartTimer;
private PlayerMovement playerMovement;
private PlayerHealth playerHealth;
// Use this for initialization
void Start () {
Cursor.visible = false;
playerMovement = player.GetComponent<PlayerMovement>();
playerHealth = player.GetComponent<PlayerHealth>();
playerMovement.enabled = false;
birdMovement.enabled = false;
followCamera.enabled = false;
}
// Update is called once per frame
void Update () {
if (gameStarted == false && Input.GetKeyUp (KeyCode.Space))
{
StartGame();
}
if (playerHealth.alive == false)
{
EndGame();
restartTimer = restartTimer + Time.deltaTime;
if (restartTimer >= restartDelay)
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}
}
private void StartGame()
{
gameStarted = true;
gameStateText.color = Color.clear;
playerMovement.enabled = true;
birdMovement.enabled = true;
}
private void EndGame()
{
gameStarted = false;
gameStateText.color = Color.white;
gameStateText.text = "Game Over!";
player.SetActive(false);
}
}
2 Answers
Thomas Lian Ødegaard
9,540 PointsI can't see that "using UnityEngine;" is included in the script, could you add that to the top of the script and try again?
Benjamin Schulz Enokian
12,393 PointsI included that line of script and it hasn't changed.
Thomas Lian Ødegaard
9,540 PointsThen are you sure that the "Follow Camera" script is attached to your Main Camera? And also check if you remembered to drag the "Player" game object from the hierarchy, to where it says "Player" and Transform at the Follow Camera script in the inspector.
Benjamin Schulz Enokian
12,393 PointsBoth the "FollowCamera" script and "Player (Transform)" script are inside the Main Camera.
Benjamin Schulz Enokian
12,393 PointsI have completely rewritten the coding for "GameState" and now it is telling me Assets/Scripts/GameState.cs(101,22); error CS1525: Unexpected symbol 'player'
Thomas Lian Ødegaard
9,540 PointsThomas Lian Ødegaard
9,540 PointsPlease enter your code, and i will check it out