void OnTriggerExit(Collider other) { if (other.gameObject.tag == "Player")//If player exits { groundSpawner.SpawnTile(); } }
private void OnCollisionExit(Collision other) { if (other.transform.tag == "Player") { groundSpawner.SpawnTile(); Destroy(gameObject, 2); } }
void OnTriggerExit(Collider other) { if (other.gameObject.tag == "Player")//If player exits { groundSpawner.SpawnTile(); } if (other.gameObject.tag == "CameraCollider")//If camera exits { Debug.Log("Camera has left"); Destroy(gameObject, 1); } }
// Update is called once per frame void FixedUpdate() { rb.AddForce(0, 0, forwardForce * Time.deltaTime, ForceMode.VelocityChange); //if (up) //{ // rb.AddForce(0, 0, forwardForce * Time.deltaTime, ForceMode.VelocityChange); // up = false; //} if (down) { rb.AddForce(0, 0, forwardForce * (-1) * Time.deltaTime, ForceMode.VelocityChange); down = false; } if (left) { rb.AddForce(turningForce * (-1) * Time.deltaTime, 0, 0, ForceMode.VelocityChange); left = false; } if (right) { rb.AddForce(turningForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange); right = false; } if (jump) { for (int i = 0; i < 7; i++) { groundSpawner.SpawnTile(false); } rb.AddForce(0, jumpingForce * Time.deltaTime, 0, ForceMode.VelocityChange); jump = false; } if (rb.position.y < (-3f)) { FindObjectOfType <GameManager>().EndGame(); } }
void OnCollisionEnter(Collision collision) { if (collision.collider.tag == "Obstacle") { Debug.Log(collision.collider.name); movement.enabled = false; crashedText.enabled = true; FindObjectOfType <GameManager>().EndGame(); } if (collision.collider.tag == "GroundTile") { Debug.Log(collision.collider.name); // groundSpawner.RemoveOldTiles(collision.collider.GetComponent<GameObject>()); groundSpawner.RemoveOldTiles(collision.collider.GetComponent <Transform>().gameObject); groundSpawner.SpawnTile(true); } }
private void OnTriggerExit(Collider other) { groundSpawner.SpawnTile(true); Destroy(gameObject, 2); }
void OnTriggerExit(Collider other) { // Debug.Log("spawntile"); groundSpawner.SpawnTile(true); Destroy(gameObject, 2); }