void OnTriggerEnter2D(Collider2D collider) { RubyController ruby = collider.GetComponent <RubyController>(); if (ruby) { if (ruby.currentHealth < ruby.maxHealth) { ruby.ChangeHealth(healthChange); Destroy(gameObject); } } }
private void OnTriggerEnter2D(Collider2D trigger) { RubyController control = trigger.GetComponent <RubyController>(); // If Ruby enters, increase health if ((control != null) && (control.currentHealth < control.maxHealth)) { control.ChangeHealth(1); Destroy(gameObject); } Debug.Log("Object that entered trigger: " + trigger); }
private void OnTriggerEnter2D(Collider2D collision) { Debug.Log("触发的对象是" + collision); RubyController rubyController = collision.GetComponent <RubyController>(); if (rubyController != null) { rubyController.ChangeHealth(1); Destroy(gameObject); } }
// Stay used to keed damaging as long as she's in the zone void OnTriggerStay2D(Collider2D other) { RubyController rController = other.GetComponent <RubyController>(); if (null != rController) { if (rController.health != 0) { rController.updateHealth(-1); //Destroy(gameObject); } } }
private void OnTriggerEnter2D(Collider2D other) { RubyController rubyController = other.GetComponent <RubyController>(); if (rubyController != null && rubyController.Health < rubyController.maxHealth) { rubyController.ChangeHealth(1); Instantiate(collectibleEffect, transform.position, Quaternion.identity); Destroy(gameObject); rubyController.PlaySound(collectedClip); } }
public void Fix() { broken = false; rigidbody2D.simulated = false; animator.SetTrigger("Fixed"); smokeEffect.Stop(); GameObject rubyControllerObject = GameObject.FindWithTag("RubyController"); rubyController = rubyControllerObject.GetComponent <RubyController>(); rubyController.ChangeScore(1); }
//Public because we want to call it from elsewhere like the projectile script public void Fix() { broken = false; rigidbody2D.simulated = false; //optional if you added the fixed animation animator.SetTrigger("Fixed"); smokeEffect.Stop(); RubyController rubyControllerObject = GameObject.FindWithTag("RubyController").GetComponent <RubyController>(); rubyControllerObject.ChangeScore(); }
void OnTriggerEnter2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null) { controller.increaseAmmo(); controller.setAmmoText(); Destroy(gameObject); controller.PlaySound(cogCollectedAudio); } }
void OnTriggerEnter2D(Collider2D other) { RubyController rubyController = other.GetComponent <RubyController>(); if (rubyController != null) { if (rubyController.health < rubyController.maxHealth) { rubyController.ChangeHealth(1); Destroy(gameObject); } } }
void OnTriggerEnter2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null) { Destroy(gameObject); controller.PlaySound(bambiCollectedAudio); NonPlayerCharacter.hasFrog = true; } }
void OnCollisionStay2D(Collision2D other) { if (repaired) { return; } RubyController controller = other.collider.GetComponent <RubyController>(); if (controller != null) { controller.ChangeHealth(-1); } }
private void OnTriggerEnter2D(Collider2D collision) { RubyController controller = collision.GetComponent <RubyController>(); if (controller != null) { if (controller.health < controller.startHealth) { controller.ChangeHealth(healthValue); Instantiate(pickupParticles, gameObject.transform.position, Quaternion.identity); Destroy(gameObject); } } }
private void OnTriggerStay2D(Collider2D collision) { //获取RubyController脚本,注意脚本是挂在角色上的,也就是这里的collision。 RubyController rubyController = collision.GetComponent <RubyController>(); Debug.Log(rubyController); //对rubyController获取进行判空处理,让代码更严谨 if (rubyController != null) { //调用血量改变参数 rubyController.ChangeHP(-1); Debug.Log(rubyController.CurrentHP); } }
// Start is called before the first frame update void Start() { rigidbody2D = GetComponent <Rigidbody2D>(); timer = changeTime; animator = GetComponent <Animator>(); GameObject controllerObject = GameObject.FindWithTag("RubyController"); //this line of code finds the RubyController script by looking for a "RubyController" tag on Ruby if (controllerObject != null) { controller = controllerObject.GetComponent <RubyController>(); //and this line of code finds the rubyController and then stores it in a variable } }
// Start is called before the first frame update void Start() { rigidbody2D = GetComponent <Rigidbody2D>(); timer = changeTime; animator = GetComponent <Animator>(); GameObject rubyControllerObject = GameObject.FindWithTag("RubyController"); if (rubyControllerObject != null) { rubyController = rubyControllerObject.GetComponent <RubyController>(); } }
// it calls this OnTriggerEnter2D function on the first frame when it detects a new Rigidbody entering the Trigger void OnTriggerEnter2D(Collider2D other) { // if enemy collide with this it will retinr null because it is not a RubyController class RubyController controller = other.GetComponent <RubyController>(); if (controller.health < controller.maxHealth) { if (controller != null) { controller.changeHealth(1); Destroy(gameObject); } } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "player") { RubyController rubyController = other.GetComponent <RubyController>(); if (rubyController.GetCurHp() < rubyController.m_fMaxHp) { rubyController.ChangeHp(1); rubyController.PlaySound(m_acPickUp); Instantiate(m_effectPickUp, transform.position, Quaternion.identity); Destroy(gameObject); } } }
private void OnTriggerEnter2D(Collider2D collision) { RubyController rc = collision.GetComponent <RubyController>(); if (rc) { //Debug.Log("Object that entered the trigger: " + collision); bool needed = rc.ChangeHealth(1); if (needed) { Destroy(gameObject); } } }
void OnTriggerEnter2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null) { if (controller.health < controller.maxHealth) { controller.ChangeHealth(1); Destroy(gameObject); } } Debug.Log("Object that entered the trigger : " + other); }
private void OnTriggerEnter2D(Collider2D collision) { Debug.Log("object that entered the trigger:" + collision); RubyController rubyController = collision.GetComponent <RubyController>(); if (rubyController != null) { if (rubyController.health < rubyController.maxHealth) { rubyController.ChangeHealth(1); Destroy(gameObject); } } }
void OnTriggerEnter2D(Collider2D iOther) { RubyController gController = iOther.GetComponent <RubyController>(); if (gController != null) { if (gController.gHealth < gController.cMaxHealth) { gController.ChangeHealth(1); Destroy(gameObject); gController.PlaySound(gCollectedClip); } } }
void OnTriggerEnter2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null) { if (controller.health < controller.maxHealth) { controller.ChangeHealth(1); ParticleSystem effectObject = Instantiate(collectEffect, transform.position, Quaternion.identity); Destroy(gameObject); } } }
void OnTriggerEnter2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null) { if (controller.health < controller.maxHealth) { controller.ChangeHealth(1); Destroy(gameObject); controller.PlaySound(collectedClip); } } }
void OnTriggerStay2D(Collider2D other) { Debug.Log("object that entred the trigger: " + other); RubyController controller = other.GetComponent <RubyController>(); // get the player controller from the other thing collied with trigger if (controller != null) // if the controller retrived is not empty { // ! the excamation is a negation value controller.ChangeHealth(-1); // call the health function and add 1 to the health of the player } }
private void OnTriggerEnter2D(Collider2D collision) { RubyController controller = collision.GetComponent <RubyController>(); if (controller != null) { // winning Debug.Log("win"); MissionPassContainer.SetActive(true); // pause game use 1 to run game again Time.timeScale = 0; } }
void OnTriggerEnter2D(Collider2D other) { RubyController rubyController = other.GetComponent <RubyController>(); if (rubyController != null) { if (rubyController.Lövedék < rubyController.maxLövedék) { rubyController.ChangeAmmo(LövedékDB); Destroy(gameObject); rubyController.PlaySound(collectedClip); } } }
private void OnTriggerStay2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null) { //if(controller.health <= controller.maxHealth) //{ controller.ChangeHealth(-1); //Destroy(gameObject); Debug.Log($"damage zone health: {controller.health}"); //} } }
void OnTriggerEnter2D(Collider2D collision) { RubyController controller = collision.GetComponent <RubyController>(); if (controller != null) { if (controller.CurrentHealth < controller.MaxHealth) { controller.ChangeHealth(25); Destroy(gameObject); controller.PlaySound(collectedClip); } } }
void OnTriggerEnter2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null) { //if (controller.health < controller.maxHealth) //{ controller.addspeed(); Destroy(gameObject); //controller.PlaySound(collectedClip); //} } }
void OnTriggerEnter2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null) { if (controller.health < controller.maxHealth) { controller.ChangeHealth(1); Destroy(gameObject); controller.PlaySound(collectedClip); GameObject HealthParticle = Instantiate(HealthPrefab, transform.position, Quaternion.identity); } } }