dell96

Members
  • Content count

    10
  • Joined

  • Last visited

Community Reputation

0 Neutral

About dell96

  • Rank
    Member

Personal Information

  • Interests
    DevOps
    Programming
  1. Spawning

    well in my game my objects spawn correctly but when the player hit the objects the spawning stop, and the gameover page shows with the replay button on the bottom when i hit the button the spawning objects don't restart they just stay where they were.but i want to spawn the objects again, like flappy bird if you die you hit the restart button and its starts spawning again
  2. Spawning

    I'm trying to make my first project but I'm stuck i don't know how to make my crate to start to spawn again when i hit the start button after i die. hoping someone can help!!! Crate.cs CrateSpawn.cs Cratework.cs GameController.cs GameManager.cs
  3. Help please !!!

    i think that to make that happen i must edit the GameManager.cs right ???
  4. Help please !!!

    what should i do to make my crate spawn again when i hit start button got any ideas that may help @frob because now you help me fix my last problem when the player hit my crate stop then my GAMEOVER page loads it has a reset button and that load the start page so i can hit the start button but then the crates wont spawn open to any ideas.... please and thank you
  5. Help please !!!

    IT WORKED !!!!!!! thanks omg thank you now i have to make it restart when i hit restart but thank you
  6. Help please !!!

    alright i try that!!, I we be writing to tell you what happens thank you for helping me, hope that your trip goes as planned.
  7. Help please !!!

    did you get a change to see the scripts
  8. Help please !!!

    i left the scripts below so you can see what i have down because i what to finish this project. i got some problems: 1- i want the crates to start spawning after i hit start 2- i also want when the player collides with the crate the crates will stop spawning and when i hit the reset the the game will start over. when i hit play in unity the crates start spawning even if i dont hit the start button if i collide with the crate it says GAMEOVER but the crates keep on spawning. LOL i know that your trying to help and a appreciate that i really do but like i said before i'm new to this. take a look at the scripts i know the scripts above got all messed up please and thanks for helping ... MoveController.cs HighscoreText.cs GameManager.cs GameController.cs Cratework.cs CrateSpawn.cs Crate.cs CountdownText.cs
  9. Help please !!!

    Go slow on me lol I'm new to this im starting off with a simple project but i'm stuck i did not understand a word that you told me lol all i can tell you is that my crates spawn perfectly but i don't know why they don't stop when i collide with them someone told to do a breakpoint but i don't know what that means or what it is. if you could explain it would help me a lot...
  10. Help please !!!

    Hi there I'm new to unity and C# and i want to make my first Android game and I'm having a problem when my player collides with the cratepipe in the game the spawning crate wont stop i need help with this i want to stop the spawning when the gameobject "player" hits the crates and stop. my player move by tilting I'm going to leave all the scripts I'm using so far please help me what should i do....? The Countdown Script using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class CountdownText : MonoBehaviour { public delegate void CountdownFinished(); public static event CountdownFinished OnCountdownFinished; Text countdown; void OnEnable() { countdown = GetComponent<Text>(); countdown.text = "3"; StartCoroutine("Countdown"); } IEnumerator Countdown() { int count = 3; for (int i = 0; i < count; i++) { countdown.text = (count - i).ToString(); yield return new WaitForSeconds(1); } OnCountdownFinished(); } } Crate Script sing UnityEngine; public class Crate : MonoBehaviour { public bool hit = false; void OnTriggerEntre2D(Collider2D collider) { if (collider.tag =="Player") { hit = true; } } } CrateSpawn Script using System.Collections; using System.Collections.Generic; using UnityEngine; public class CrateSpawn : MonoBehaviour { List<Cratework> cratePool; int index = -1; public GameObject cratePrefab; public float spawnTime = 4f; public float speed = 35; public int poolSize = 5; public bool isRunning = true; [HideInInspector] public bool hit = false; void Start() { cratePool = new List<Cratework>(); for (int i = 0; i < poolSize; i++) { var crate = (GameObject)Instantiate(cratePrefab, new Vector3(0, 8, 0), Quaternion.identity); cratePool.Add(crate.GetComponent<Cratework>()); } StartCoroutine(SpawnCrate()); } void Update() { for (int i = 0; i <= poolSize; i++) { var crate = cratePool[i]; crate.transform.position += new Vector3(0, speed * Time.deltaTime, 0); if (crate.hit) { hit = true; StopAllCoroutines(SpawnCrate()); } } } IEnumerator SpawnCrate() { while (isRunning) { index++; index %= poolSize; var crate = cratePool[index]; float x = Random.Range(-2, 2); crate.transform.position = new Vector3(x, -6, 0); yield return new WaitForSeconds(spawnTime); } } } CrateWork Script using UnityEngine; public class Cratework : MonoBehaviour { public Crate left; public Crate right; public bool hit = false; void Update () { if (left.hit || right.hit) { hit = true; } } } GameController Script using System.Collections; using System.Collections.Generic; using UnityEngine; public class GameController : MonoBehaviour { public CrateSpawn crateSpawn; void ChangeSpeed(float speed) { crateSpawn.speed = speed; } void Update() { if (crateSpawn.hit) { ChangeSpeed(0); } } } GameManager Script using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class GameManager : MonoBehaviour { public delegate void GameDelegate(); public static event GameDelegate OnGameStarted; public static event GameDelegate OnGameOverConfirmed; public static GameManager Instance; public GameObject startPage; public GameObject gameOverPage; public GameObject countdownPage; public Text scoreText; enum PageState { None, Start, GameOver, Countdown } int score = 0; bool gameover = true; public bool GameOver { get { return gameover; } } void Awake() { Instance = this; } void OnEnable() { CountdownText.OnCountdownFinished += OnCountdownFinished; MoveController.OnPlayerDied += OnPlayerDied; MoveController.OnPlayerScored += OnPlayerScored; } void OnDisable() { CountdownText.OnCountdownFinished -= OnCountdownFinished; MoveController.OnPlayerDied -= OnPlayerDied; MoveController.OnPlayerScored -= OnPlayerScored; } void OnCountdownFinished() { SetPageState(PageState.None); OnGameStarted(); score = 0; gameover = false; } void OnPlayerDied() { gameover = true; int savedScore = PlayerPrefs.GetInt("HighScore"); if (score > savedScore) { PlayerPrefs.SetInt("HighScore", score); } SetPageState(PageState.GameOver); } void OnPlayerScored() { score++; scoreText.text = score.ToString(); } void SetPageState(PageState state) { switch (state) { case PageState.None: startPage.SetActive(false); gameOverPage.SetActive(false); countdownPage.SetActive(false); break; case PageState.Start: startPage.SetActive(true); gameOverPage.SetActive(false); countdownPage.SetActive(false); break; case PageState.GameOver: startPage.SetActive(false); gameOverPage.SetActive(true); countdownPage.SetActive(false); break; case PageState.Countdown: startPage.SetActive(false); gameOverPage.SetActive(false); countdownPage.SetActive(true); break; } } public void ConfirmGameOver() { OnGameOverConfirmed();//event scoreText.text = "0"; SetPageState(PageState.Start); } public void StartGame() { SetPageState(PageState.Countdown); } } HighScore Script using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class HighscoreText : MonoBehaviour { Text highscore; void OnEnable() { highscore = GetComponent<Text>(); highscore.text = ": " + PlayerPrefs.GetInt("HighScore").ToString(); } } MoveController Script using System.Collections; using System.Collections.Generic; using UnityEngine; public class MoveController : MonoBehaviour { public delegate void PlayerDelegate(); public static event PlayerDelegate OnPlayerDied; public static event PlayerDelegate OnPlayerScored; public float speed = 0.25f; public Vector3 startPos; Rigidbody2D rigidbody; GameManager game; void Start() { rigidbody = GetComponent<Rigidbody2D>(); game = GameManager.Instance; } void OnEnable() { GameManager.OnGameStarted += OnGameStarted; GameManager.OnGameOverConfirmed += OnGameOverConfirmed; } void OnDisable() { GameManager.OnGameStarted -= OnGameStarted; GameManager.OnGameOverConfirmed -= OnGameOverConfirmed; } void OnGameStarted() { rigidbody.velocity = Vector3.zero; rigidbody.simulated = true; } void OnGameOverConfirmed() { transform.localPosition = startPos; } void Update() { transform.Translate(Input.acceleration.x * speed, 0, 0); } void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.tag == "ScoreZone") { OnPlayerScored(); //play a sound //get a point } if (col.gameObject.tag == "DeadZone") { OnPlayerDied(); rigidbody.simulated = false; } } }