// collission checker private void OnTriggerEnter2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); RubyPlatformerControl controller2 = other.GetComponent <RubyPlatformerControl>(); if (controller != null) { if (controller.health < controller.maxHealth) { // breytir health, eyðir objectinu, synir effect og spilar hljoðið controller.ChangeHealth(1); Destroy(gameObject); HealthCollisionEffect = Instantiate(HealthEffect, transform.position, Quaternion.identity) as ParticleSystem; HealthCollisionEffect.Play(); controller.PlaySound(collectedClip); } } if (controller2 != null) { if (controller2.health < controller2.maxHealth) { // breytir health, eyðir objectinu, synir effect og spilar hljoðið controller2.ChangeHealth(1); Destroy(gameObject); HealthCollisionEffect = Instantiate(HealthEffect, transform.position, Quaternion.identity) as ParticleSystem; HealthCollisionEffect.Play(); controller2.PlaySound(collectedClip); } } }
// collission checker private void OnTriggerEnter2D(Collider2D other) { RubyPlatformerControl player = other.GetComponent <RubyPlatformerControl>(); // gerir effect, hljoð og loadar nytt scene if (player != null) { HealthCollisionEffect = Instantiate(HealthEffect, transform.position, Quaternion.identity) as ParticleSystem; HealthCollisionEffect.Play(); player.PlaySound(collectedClip); StartCoroutine(WinLoad()); } }