void OnTriggerEnter2D(Collider2D other) { if (other.GetComponentInParent<PlayerController>()) { other.GetComponentInParent<PlayerController>().respawnPoint = transform; } }
//public int bottomDamage; void OnTriggerEnter2D(Collider2D other) { if(other.name == "EnemyBody"){ other.GetComponentInParent<EnemyHealthManager>().HurtEnemy(bodyDamage);//GetComponenetInParent grabs the actual enemy game object rather than the individual hit boxes other.GetComponentInParent<EnemyHealthManager>().knockBackEnemySides(other, gameObject.transform); //GetComponent<AudioSource>().Play (); PlayerHealthManager.BouncePlayer(this.GetComponent<Collider2D>(), other.gameObject); //Debug.Log("Enemy Body"); } else if(other.name == "EnemyHead"){ other.GetComponentInParent<EnemyHealthManager>().HurtEnemy(headDamage); other.GetComponentInParent<EnemyHealthManager>().knockBackEnemySides(other, gameObject.transform); //GetComponent<AudioSource>().Play (); PlayerHealthManager.BouncePlayer(this.GetComponent<Collider2D>(), other.gameObject); //Debug.Log("Enemy Head"); } // else if(other.name == "EnemyBottom"){ // other.GetComponentInParent<EnemyHealthManager>().HurtEnemy(bottomDamage); // other.GetComponentInParent<EnemyHealthManager>().knockBackEnemySides(other, gameObject.transform); // GetComponent<AudioSource>().Play (); // //Debug.Log ("Enemy Bottom"); // } else if(other.name == "EnemyLance"){ //bounce back happens here other.GetComponentInParent<EnemyHealthManager>().knockBackEnemySides(other, gameObject.transform); GetComponent<AudioSource>().Play (); } }
void OnTriggerEnter2D(Collider2D col) { if(col.tag == "LightDamaging") { lightDamage(1); } else if(col.tag == "Waterfall") { lightDamage(2); } else if(col.tag == "Lamp") { if(col.GetComponentInParent<LampCollision>().NotLit) { if(currentLight < 8) { currentLight += 1; lightSource.intensity +=1f; lightSource.range +=1f; } player.GetComponent<PlayerController>().PlayerDamage(-25); } col.GetComponentInParent<LampCollision>().lightUp(); } else if(col.tag == "TrickDamaging") { if(currentLight > 3) { Destroy (col.gameObject); } } }
void OnTriggerEnter2D(Collider2D collider) { if (collider.gameObject.layer == _enemyLayer) { if (_owner.myTeam == WeaponHolder.Team.ENEMY) return; Enemy enemy = collider.GetComponentInParent<Enemy>(); if (enemy != null) { _owner.weapon.ApplyKnockback(enemy.mover, rigidBody.velocity); enemy.LoseHealth(_owner.weapon.strength); ownerFiringSystem.DestroyObject(gameObject); } } else if (collider.gameObject.layer == _sceneryLayer) { ownerFiringSystem.DestroyObject(gameObject); } else if (collider.gameObject.layer == _playerLayer) { PlayerController player = collider.GetComponentInParent<PlayerController>(); if (player != null) { _owner.weapon.ApplyKnockback(player.mover, rigidBody.velocity); player.GetHit(); ownerFiringSystem.DestroyObject(gameObject); } } //ownerFiringSystem.DestroyObject(gameObject); }
void OnTriggerEnter2D(Collider2D coll) { if (coll.GetComponentInParent<Umbrella>() != null) { Umbrella u = coll.GetComponentInParent<Umbrella>(); u.CollideWithBird(this); toDestroy = true; } }
void OnTriggerEnter2D(Collider2D collider) { if (spawnID == collider.GetComponentInParent<Movement>().GetID() && collider.GetComponentInParent<Movement>().GetEggs() != 0)//If player of correct ID collides with me and they're carrying eggs then bank their eggs { Debug.Log("Player" + collider.GetComponentInParent<Movement>().GetID() + " Banked " + collider.GetComponentInParent<Movement>().GetEggs() + " Eggs"); collider.GetComponentInParent<Movement>().BankEggs(); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Ball") { other.transform.position = ballSpawn.position; // Reset velocity other.GetComponentInParent<Rigidbody2D> ().isKinematic = true; other.GetComponentInParent<Rigidbody2D> ().isKinematic = false; } }
void OnTriggerEnter2D(Collider2D other) { if(other.name == "EnemyHead"){ other.GetComponentInParent<EnemyHealthManager>().HurtEnemy(1); other.GetComponentInParent<EnemyHealthManager>().knockBackEnemySides(other, gameObject.transform); PlayerHealthManager.BouncePlayer(this.GetComponent<Collider2D>(), other.gameObject); //Debug.Log ("worked"); } }
void OnTriggerExit2D(Collider2D col) { if(col.GetComponent<SpriteObject>()) { col.GetComponent<SpriteObject>().FellOffEdge(); } else if (col.GetComponentInParent<SpriteObject>()) { col.GetComponentInParent<SpriteObject>().FellOffEdge(); } }
void OnTriggerEnter2D(Collider2D collider) { if (isSpawned) { if (collider.GetComponentInParent<Movement>().GetTag() == "Player" && !collider.GetComponentInParent<Movement>().CheckEggs()) { collider.GetComponentInParent<Movement>().AddEgg(); DeSpawn(); } } }
// for interaction if it is an object void OnTriggerEnter2D(Collider2D collider) { if (isObject&&collider.CompareTag ("Player")) { master = collider.GetComponentInParent<MasterPlayer>(); master.elements[currentColour] = true; collider.GetComponentInParent<ModeChange>().currentColour = currentColour; // get the master player // get the current colour this sphere is possessing // set the element to true so that the player can access it Destroy(transform.gameObject); // destroy this object after using it } }
void OnTriggerEnter2D(Collider2D other) { if(other.tag == "Enemy"){ other.GetComponentInParent<EnemyHealthManager>().HurtEnemy(thisBulletDamage); other.GetComponentInParent<EnemyHealthManager>().knockBackEnemySides(other, playerPosition); Destroy (gameObject); } if(other.tag == "TopWall"){ Destroy (gameObject); } }
// Update is called once per frame void OnTriggerEnter2D (Collider2D other) { if(other.CompareTag(Tags.player)) { if (other.GetComponentInParent<Stats>().side != _side) { InputToAction otherController = other.GetComponentInParent<InputToAction>(); if (!modifiers.ContainsKey(otherController)) { modifiers[otherController] = otherController.maxSpeedTracker.addModifier(speedNerf); } } } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { if (doFriendlyFire) return; if (!immuneToShipCollision) OnHit(false); if (!doesntKill) other.GetComponentInParent<PlayerLife>().OnHit(); } else if (other.tag == "PlayerShield") { OnHit(true); other.transform.parent.GetComponentInChildren<PlayerShield>().OnHit(); } else if (doFriendlyFire && ((other.tag == "Enemy") || (other.tag == "EnemyAttachment"))) { if (!immuneToShipCollision) OnHit(true); other.GetComponentInParent<EnemyLife>().OnHit(true); } }
void OnTriggerStay2D(Collider2D collider) { if (collider.tag == "Player" && isBombExploded) { collider.GetComponentInParent<Movement>().ReSpawn(); Destroy(gameObject); Debug.Log("Player " + collider.tag + "hit by bomb"); } if (collider.tag == "Egg" && isBombExploded) { collider.GetComponentInParent<Egg>().DeSpawn(); Destroy(gameObject); Debug.Log("Player " + collider.tag + "hit by bomb"); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Enemy" || other.tag == "EnemyAttachment") { var victimPrimaryLife = other.GetComponentInParent<EnemyLife>(); var victimSecondary = FindClosestEnemy(victimPrimaryLife.gameObject); var victimSecondaryLife = victimSecondary.GetComponentInParent<EnemyLife>(); if (victimSecondary != null) { victimPrimaryLife.doFriendlyFire = true; victimPrimaryLife.doesntKill = false; victimSecondaryLife.doFriendlyFire = true; victimSecondaryLife.doesntKill = false; victimPrimaryLife.attachElectricEffect(victimSecondary); var posPrimary = victimPrimaryLife.rigidbody2D.position; victimPrimaryLife.GetComponent<EnemyMovementBase>().Freeze(); victimSecondary.GetComponent<EnemyMovementBase>().ForceMovement(posPrimary, magnetForce); AudioSource.PlayClipAtPoint(magnetSound, this.rigidbody2D.position); controller.Remove(); } else { controller.Remove(); } } }
void OnTriggerStay2D(Collider2D collide) { if (collide.tag == "Player") { if(collide.transform.position.x>this.transform.position.x){ collide.GetComponentInParent<Transform>().Translate(new Vector2(10, 0)*Time.deltaTime, Space.World); }else{ collide.GetComponentInParent<Transform>().Translate(new Vector2(-10,0)*Time.deltaTime, Space.World); } } }
void OnTriggerEnter2D(Collider2D collider) { Rigidbody2D body = null; Dino dino = collider.GetComponentInParent<Dino>(); if(!dino || !dino.isAlive) return; switch(dino.player) { case Dino.Player.Player1: body = GameObject.Find("Blue_Body").GetComponent<Rigidbody2D>(); break; case Dino.Player.Player2: body = GameObject.Find("Red_Body").GetComponent<Rigidbody2D>(); break; } if(body) body.drag = 100; Announcer.instance.announce(Announcer.Announcement.OutOfBounds); if(dino && dino.Health > 0) dino.die(Dino.DeathType.Lava); if(fireEruption && body && !fired) { ParticleSystem eruption = GameObject.Instantiate(fireEruption); Vector3 position = body.transform.position; eruption.transform.position = new Vector3( position.x, position.y - 5, position.z); eruption.Play(); fired = true; StartCoroutine(showSkeleton(dino)); } }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "EnemyHead") { animator = other.GetComponentInParent<Animator>(); //animator = other.GetComponent<Animator>(); animator.SetBool("isSquished", true); rb2d.velocity = new Vector2(rb2d.velocity.x, bounceOnEnemy); } //Player playerData = GetComponent<Player>(); //if (other.tag == "Enemy" ) //&& playerData.grounded == false) //{ // animator = other.GetComponent<Animator>(); // animator.SetBool("isSquished", true); // float i = 0; // do // { // i = animator.GetCurrentAnimatorStateInfo(0).normalizedTime; // } while (i != 1); // Destroy(other.gameObject); // GameObject go = GameObject.Find("mainObject"); // UI ui = go.GetComponent<UI>(); // GameControl.control.AddPoint(); //} }
void OnTriggerEnter2D(Collider2D other) { if(other.tag == "Enemy") other.GetComponentInParent<EnemyHealthManager2>().damageEnemy(rangedDamage); Instantiate(projectileHitParticle, transform.position, transform.rotation); Destroy(gameObject); }
void OnTriggerEnter2D( Collider2D col ) { var ship = col.GetComponentInParent<ShipController>(); if ( ship ) { ship.AddFuel( FuelAmount ); Destroy( this.gameObject ); } }
void OnTriggerEnter2D(Collider2D coll) { if (coll.GetComponentInParent<HeroControlTemp>() != null) { HeroObject = coll.GetComponentInParent<HeroTemp>(); if(!HeroObject._cannCarry){ ObjectRigidbody.isKinematic = false; ObjectRigidbody.constraints = RigidbodyConstraints2D.None; HeroInn = true; HeroObject.SendMessage("TriggerEscada", this); } }else if(coll.CompareTag("Floor")){ ObjectRigidbody.gravityScale = 0; ObjectRigidbody.isKinematic = true; ObjectRigidbody.constraints = RigidbodyConstraints2D.FreezeAll; } }
void OnTriggerEnter2D(Collider2D other) { //Debug.Log ("Player OnTriggerEnter2D : " + other.name); // トリガーチェック if (other.tag == "EnemyArm") { EnemyController enemyCtrl = other.GetComponentInParent<EnemyController>(); //Debug.Log(string.Format("EnemyArm Hit {0}",ec.attackEnable)); if (enemyCtrl.attackEnabled) { enemyCtrl.attackEnabled = false; playerCtrl.dir = (playerCtrl.transform.position.x < enemyCtrl.transform.position.x) ? +1 : -1; playerCtrl.AddForceAnimatorVx(-enemyCtrl.attackNockBackVector.x); playerCtrl.AddForceAnimatorVy( enemyCtrl.attackNockBackVector.y); playerCtrl.ActionDamage (enemyCtrl.attackDamage); } } else if (other.tag == "EnemyArmBullet") { FireBullet fireBullet = other.transform.GetComponent<FireBullet>(); if (fireBullet.attackEnabled) { fireBullet.attackEnabled = false; playerCtrl.dir = (playerCtrl.transform.position.x < fireBullet.transform.position.x) ? +1 : -1; playerCtrl.AddForceAnimatorVx(-fireBullet.attackNockBackVector.x); playerCtrl.AddForceAnimatorVy( fireBullet.attackNockBackVector.y); playerCtrl.ActionDamage (fireBullet.attackDamage); Destroy (other.gameObject); } } }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "bean") { BeanController bean = other.gameObject.GetComponent<BeanController>(); bean.Destroy(); beanRenderer.enabled = true; } if (other.tag == "goal") { if (beanRenderer.enabled) { Rigidbody2D rb = myBean.GetComponent<Rigidbody2D>(); rb.isKinematic = false; rb.gravityScale = 3f; } } if (other.tag == "enemy") { if(beanRenderer.enabled){ Rigidbody2D beanrb = myBean.GetComponent<Rigidbody2D>(); beanrb.isKinematic = true; beanRenderer.enabled = false; BeanSpawner.SpawnNewBean(); } other.GetComponentInParent<Animator>().SetTrigger("Strike"); StartCoroutine(Shake()); } }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Boss") { Boss enemy = other.GetComponentInParent<Boss>(); enemy.Hurt(playerAttackingController.AttackDamage); } else if (other.tag == "Golem") { BadGuy badGuy = other.GetComponentInParent<BadGuy>(); badGuy.Hurt(playerAttackingController.AttackDamage); } else if (other.tag == "CrossEnemy") { CrossEnemy crossEnemy = other.GetComponentInParent<CrossEnemy>(); crossEnemy.Hurt(playerAttackingController.AttackDamage); } else if (other.tag == "Player") { ProtaController prota = other.GetComponentInParent<ProtaController>(); prota.Life -= playerAttackingController.AttackDamage; } }
void React(Collider2D col) { Enemy enemy = col.GetComponentInParent<Enemy>(); if (enemy != null) { healthMgr.TakeDamage(enemy.contactDamage, false); } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag=="ant") { other.GetComponentInParent<AntBehavior>().DieWithBlood(); } }
void OnTriggerEnter2D(Collider2D coll) { if (coll.tag == "Sword" && !isCut) { isCut = true; grassCutAudio.Play (); animator.SetBool("cutGrass", true); coll.GetComponentInParent<playerController>().grassCut++; if (coll.GetComponentInParent<playerController>().grassCut >= 12) { successAudio.Play (); leftKey.gameObject.SetActive (true); } } }
void OnTriggerEnter2D(Collider2D other) { Hero hero = other.GetComponentInParent<Hero> (); if (hero != null && hero.transform.position.y > transform.position.y) { hero.Jump(maxHeightMultiplier); } }
protected void OnTriggerEnter2D(Collider2D other) { //Debug.Log(gameObject.name + " hits " + other.name); // Calculate the force to apply Vector2 force = transform.TransformVector(Vector3.right); force.y = 0.5f; // add a bit of upward force force *= (strongMode ? strongKnockbackValue : weakKnockbackValue); CharDamage dam = other.GetComponent<CharDamage>(); if (dam != null) dam.ApplyDamage(strongMode ? strongDamageValue : weakDamageValue); CharController charCtrl = other.GetComponent<CharController>(); if (charCtrl != null) { charCtrl.TakeHit(force); } else { Rigidbody2D targetRbody = other.GetComponentInParent<Rigidbody2D>(); if (targetRbody != null) targetRbody.AddForce(force, ForceMode2D.Impulse); } SoundManager.instance.FindPlayerFX(GetComponentInParent<CharController>().playerNum, "hit"); if (hitEffect != null) { hitEffect.transform.position = transform.position; hitEffect.SetActive(true); } }