protected void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Player")) { ScoreManger.AddPoints(pointsToAdd); Destroy(gameObject); } }
void OnTriggerEnter2D(Collider2D other) { if (other.name == "Player") { Instantiate(deathEffect, transform.position, transform.rotation); ScoreManger.AddPoints(-pointsOnDeath); Destroy(gameObject); } }
// Update is called once per frame void Update() { if (enemyHealth <= 0) { Instantiate(deathEffect, transform.position, transform.rotation); ScoreManger.AddPoints(pointsOnDeath); Destroy(gameObject); } }
void OnTriggerEnter2D(Collider2D other) { if (other.GetComponent <PlayerController>() == null) { return; } ScoreManger.AddPoints(pointsToAdd); coinSoundEffect.Play(); Destroy(gameObject); }
public IEnumerator RespawbPlayerCo() { Instantiate(deathParticle, player.transform.position, player.transform.rotation); player.enabled = false; player.GetComponent <Renderer>().enabled = false; camera.isFollowing = false; //gravityStore = player.GetComponent<Rigidbody2D>().gravityScale; //player.GetComponent<Rigidbody2D>().gravityScale = 0f; //player.GetComponent<Rigidbody2D>().velocity = Vector2.zero; ScoreManger.AddPoints(-pointPenaltyOnDeath); Debug.Log("Player Reapawn"); yield return(new WaitForSeconds(respawnDelay)); //player.GetComponent<Rigidbody2D>().gravityScale = gravityStore; player.transform.position = currentCheckpoint.transform.position; player.knockbackCount = 0; player.enabled = true; player.GetComponent <Renderer>().enabled = true; healthManager.FullHealth(); healthManager.isDead = false; camera.isFollowing = true; Instantiate(respawnParticle, currentCheckpoint.transform.position, currentCheckpoint.transform.rotation); }
// Update is called once per frame void Update() { if (enemyHealth <= 0) { Instantiate(deathEffect, transform.position, transform.rotation); ScoreManger.AddPoints(pointsOnDeath); if (transform.localScale.y > minSize) { GameObject clone1 = Instantiate(bossPrefab, new Vector3(transform.position.x + 0.5f, transform.position.y, transform.position.z), transform.rotation) as GameObject; GameObject clone2 = Instantiate(bossPrefab, new Vector3(transform.position.x - 0.5f, transform.position.y, transform.position.z), transform.rotation) as GameObject; clone1.transform.localScale = new Vector3(transform.localScale.y * 0.7f, transform.localScale.y * 0.7f, transform.localScale.z); clone1.GetComponent <BossHealthManager>().enemyHealth = 10; clone2.transform.localScale = new Vector3(transform.localScale.y * 0.7f, transform.localScale.y * 0.7f, transform.localScale.z); clone2.GetComponent <BossHealthManager>().enemyHealth = 10; } Destroy(gameObject); } }