void OnCollisionEnter2D (Collision2D collision){ Vector2 tweak = new Vector2 (Random.Range(0f, 0.2f), Random.Range(0f, 0.2f)); if(hasStarted) { audio.Play(); rigidbody2D.velocity += tweak; } }
void OnCollisionExit2D(Collision2D other) { if(other.transform.tag == "movingPlat") { transform.parent = null; } }
public void OnCollisionEnter2D(Collision2D other) { Debug.Log ("명중"); if (other.gameObject.CompareTag ("Enemy")) { var Enemy = other.gameObject; if (Enemy.name == "Enemy_T2" || Enemy.name == "Enemy_T3") { Enemy.GetComponent<AIEnemy> ().HP -= 20; if(other.gameObject.GetComponent<AIEnemy>().HP<=0) { other.gameObject.GetComponent<AIEnemy>().Reset(); other.gameObject.SetActive(false); } } if (Enemy.name == "Enemy_T1") { Enemy.GetComponent<Seek2> ().HP -= 20; if(other.gameObject.GetComponent<Seek2>().HP<=0) { other.gameObject.GetComponent<Seek2>().Reset(); other.gameObject.SetActive(false); } } var dir = (other.transform.localPosition - this.transform.localPosition).normalized; other.rigidbody.AddForce(dir*0.00005f); frame = 0; this.gameObject.SetActive(false); this.transform.localPosition = fVec; } else { frame = 0; this.gameObject.SetActive(false); this.transform.localPosition = fVec; } }
//collision detection void OnCollisionEnter2D(Collision2D hit) { if(hit.gameObject.tag == "Player") { isTouching = true; } }
void OnCollisionEnter2D(Collision2D other) { if(other.transform.tag == "movingPlat") { transform.parent = other.transform; } }
/* public virtual Player GetOwner() { return owner; }*/ public virtual void OnCollisionEnter2D(Collision2D collision) { bool isWall = collision.gameObject.tag == "Wall"; TakeDamage takeDamage = collision.gameObject.GetComponent<TakeDamage>(); if (takeDamage == null) { takeDamage = collision.gameObject.GetComponentInChildren<TakeDamage>(); } if (isWall || takeDamage != null) { if (isWall) { rigidbody2d.velocity = Vector2.zero; rigidbody2d.angularVelocity = 0; ((CircleCollider2D) gameObject.GetComponent<CircleCollider2D>()).enabled = false; } else { print(takeDamage); TakeDamage ownerTakeDamage = weapon.transform.parent.parent.gameObject.GetComponentInChildren<TakeDamage>(); if (ownerTakeDamage != takeDamage) { takeDamage.Damage(weapon.damage, collision.gameObject); Destroy(gameObject); } } } }
void OnCollisionEnter2D(Collision2D coll) { Debug.Log ("Collision"); if (coll.gameObject.name == "Player") { gameController.onExit(); } }
void OnCollisionEnter2D(Collision2D coll) { if(coll.gameObject.tag == "wall") { } }
void OnCollisionStay2D(Collision2D collision) { if (collision.gameObject.tag == "Barrier" || collision.gameObject.tag == "Tree1" || collision.gameObject.tag == "Tree2" || collision.gameObject.tag == "Tree3" || collision.gameObject.tag == "Apple" || collision.gameObject.tag == "Player" || collision.gameObject.tag == "NPC") { gameObject.SendMessage("SelectAnotherPath"); } }
void OnCollisionEnter2D(Collision2D Entity) { if(Entity.gameObject.tag == "Ground") { playerData.grounded = true; } }
void OnCollisionExit2D(Collision2D col) { if (col.gameObject.tag == "Ground") { if (stayDown) { if (col.transform.position.y < transform.position.y) { RaycastHit2D hit = Physics2D.Raycast((Vector2)transform.position + colider.offset, Vector2.down, distance); if (hit) { Vector2 normal = -hit.normal; RaycastHit2D hit2 = Physics2D.Raycast((Vector2)transform.position + colider.offset, normal, distance); if (hit2) { Vector2 vec = hit2.point - ((Vector2)transform.position + colider.offset); vec = vec.normalized * (vec.magnitude - colider.radius) * errorPercentage; vec.x = 0; rBody.MovePosition(transform.position + (Vector3)vec); } rBody.velocity = new Vector2(rBody.velocity.x, Mathf.Min(-5f, rBody.velocity.y)); } } } } }
void OnCollisionEnter2D(Collision2D coll) { if (coll.collider.CompareTag ("Player")) { collided = true; if (cShip.sliderValue2 >= energyReq) { cShip.sliderValue2 -= energyReq; cShip.ProgressBar2.value = cShip.sliderValue2; //Destroy (this.gameObject); enemyAnim.SetBool("Dead", true); this.enabled = false; this.GetComponent<BoxCollider2D>().enabled = false; Invoke ("SelfDestroy",deathSpeed); cShip.collidedShips--; } else { //cShip.StrengthScript.StrengthCount--; //cShip.StrengthScriptShadow.StrengthCount--; //if( cShip.StrengthScript.StrengthCount == 0) //{ cShip.shipAnim.SetBool ("isDead", true); //} } } }
void OnCollisionEnter2D(Collision2D col) { if( col.gameObject.tag=="Player"){ Destroy(this.gameObject); MusicControl._instant.PlayAwardSound(); } }
void OnCollisionStay2D(Collision2D col) { if (col.gameObject.tag == "Player") { col.gameObject.GetComponent<Player>().takeDamage(enemyStats.Damage); } }
public virtual void OnCollisionEnter2D(Collision2D collision) { if(collision.gameObject.GetComponent<SH_Projectile>()== null) return; collision.gameObject.GetComponent<SpriteRenderer>().enabled = false; // set so buildings block fireing lanes }
void OnCollisionEnter2D(Collision2D collision) { if (!haColisionadoConElJugador && (collision.collider.gameObject.name == "PataInferiorDerechaB" || collision.collider.gameObject.name == "PataInferiorIzquierdaB")) { NotificationCenter.DefaultCenter().PostNotification(this,"IncrementarPuntos",puntosGanados); haColisionadoConElJugador = true; } }
//Catch Collisions void OnCollisionEnter2D(Collision2D collision) { //Set forces to zero bullBody.velocity = Vector3.zero; bullBody.angularVelocity = 0; //Set the trigger for the bullet to pop actionCamera.impactPause(); animator.SetTrigger ("Collide"); //Check if it is an enemy if (collision.gameObject.tag == "Enemy") { //Shake for damage actionCamera.startShake (); //Get the enemy object Enemy e = (Enemy)collision.gameObject.GetComponent ("Enemy"); //Find our damage, and set it int damage = strength * (speed / 20); int newHealth = e.getHealth() - damage; e.setHealth (newHealth); } //Lastly remove all force and delete the bullet StartCoroutine("BulletHit"); }
void OnCollisionEnter2D(Collision2D target) { if (target.gameObject.tag == "Deadly") { OnDestroy(); } }
void OnCollisionEnter2D(Collision2D collision) { if (!Utilities.IsPlayer(collision.gameObject)) { return; } transform.root.GetComponent<Entity>().OnTouch(Utilities.Choose(touch), collision.contacts[0].point, collision.contacts[0].normal); }
// Use this for initialization void OnCollisionEnter2D(Collision2D other) { var damagable = other.gameObject.GetComponent<Damagable> (); if (damagable) { damagable.DealDamage(power); } }
//Load next level when player touches gem public void OnCollisionEnter2D(Collision2D TriggerObject) { if (TriggerObject.gameObject.tag == "Player") { Application.LoadLevel(8); } }
void OnCollisionEnter2D (Collision2D c){ if (c.gameObject.tag == "Asteroid"){ Destroy (c.gameObject); //sound effect event here!! } }
void OnCollisionEnter2D(Collision2D other) { if (other != null && other.gameObject.tag == "Player") { //transform.root.GetComponentInChildren<RotationDoor>().InCollider(true); //print("collide enter"); } }
void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.layer == LayerMask.NameToLayer("Terrain")) { Attach(); } }
void OnCollisionEnter2D(Collision2D collide){ if (collide.gameObject.CompareTag ("leftwall") || collide.gameObject.CompareTag ("rightwall")) { clickAudio.Play (); } if (collide.gameObject.CompareTag ("heart")) { kissAudio.Play (); Destroy(collide.gameObject); Debug.Log("It's a heart!"); score += 1; scoreText.text = "Hearts Stolen : "+ score; } if (collide.gameObject.CompareTag ("goal") || collide.gameObject.CompareTag ("land")) { weeAudio.Play (); deathanim.Play (); death = true; Debug.Log("I'm happy to die for my master"); if (collide.gameObject.CompareTag ("goal")) { goalText.text = "Yay!\n You finished the ritual\nsuccessfully with "+ score + " hearts";} if (collide.gameObject.CompareTag ("land")) { goalText.text = "Buu!\n You finished the ritual\nunsuccessfully with "+ score + " hearts";} } }
// when enemy moves it checks when the colliders are not touching anymore CollisionExit void OnCollisionExit2D(Collision2D otherCollider) { if (otherCollider.gameObject.CompareTag ("Ground")) { this._isGrounded = true; this._isFrontGround = true; } }
void OnCollisionEnter2D(Collision2D other) { Fish otherFish = other.transform.GetComponent<Fish>(); if (otherFish) otherFish.Despawn(); }
void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag == "Rock" || col.gameObject.tag == "BonusAlien") { DestroyProj(); } }
void OnCollisionExit2D(Collision2D hit) { if(hit.gameObject.tag == "Player") { isTouching = false; } }
//Detects collisions void OnCollisionEnter2D(Collision2D col) { //In minigame 1 simply destroy the fruits if (col.gameObject.tag == "Cherry" || col.gameObject.tag == "Lemon" || col.gameObject.tag == "Orange" || col.gameObject.tag == "Banana") { Destroy(col.gameObject); } //In minigame 2 also subtracts points if (col.gameObject.tag == "Cherry_2" || col.gameObject.tag == "Lemon_2" || col.gameObject.tag == "Orange_2" || col.gameObject.tag == "Banana_2") { Destroy(col.gameObject); } }
public void OnCollisionExit2D(Collision2D collision) { gidebilirsin = true; }
void OnCollisionEnter2D(Collision2D col) { }
void OnCollisionEnter2D(Collision2D collision) { if (_isColliding) { return; } _isColliding = true; var go = Instantiate(BulletHitAnimationPrefab, new Vector3(RigidbodyComponent.position.x, RigidbodyComponent.position.y, -3.0f), Quaternion.identity); Destroy(go, 1.0f); var objects = Physics2D.OverlapCircleAll(RigidbodyComponent.position, GlobalConstants.BulletSplashRadius); AudioSource asc = go.GetComponent <AudioSource>(); asc.Play(); int playerLayer = LayerMask.NameToLayer("Player"); int enemiesLayer = LayerMask.NameToLayer("Enemies"); foreach (var obj in objects) { int layerToCheck = obj.gameObject.layer; if (layerToCheck == playerLayer || layerToCheck == enemiesLayer) { float distance = Vector2.Distance(RigidbodyComponent.position, obj.attachedRigidbody.position); if (distance < 1.0f) { distance = 1.0f; } int distanceSquared = (int)Mathf.Pow(distance, 2.0f); if (layerToCheck == enemiesLayer) { var enemy = obj.gameObject.GetComponentInParent <EnemyBase>(); int damageDealt = (int)((float)(GlobalConstants.BulletSplashDamage / distanceSquared) * enemy.Defence); if (damageDealt != 0) { enemy.ReceiveDamage(damageDealt); } //Debug.Log(obj.attachedRigidbody.position + " took " + damageDealt + " damage"); } else if (layerToCheck == playerLayer) { var player = obj.gameObject.GetComponentInParent <TankPlayer>(); int damageDealt = (int)((float)(GlobalConstants.BulletSplashDamage / distanceSquared) * GlobalConstants.TankDefence); if (damageDealt != 0) { player.ReceiveDamage(damageDealt); } //Debug.Log("Player took " + damageDealt + " damage"); } } } Destroy(gameObject); }
private void OnCollisionEnter2D(Collision2D collision) { print("OnCollisionEnter2d"); }
public void OnCollisionEnter2D(Collision2D collider) { }
void OnCollisionStay2D(Collision2D coll) { callIfExist(idOnCollisionStay2D, coll); }
void OnCollisionExit2D(Collision2D coll) { callIfExist(idOnCollisionExit2D, coll); }
private void OnCollisionExit2D(Collision2D collision) { collideOnBlock = false; }
private void OnCollisionEnter2D(Collision2D collision) { GetComponent<AudioSource>().Play(); }
void OnCollisionExit2D(Collision2D cd) { cd.collider.transform.parent = null; cd.collider.transform.localRotation = Quaternion.identity; }
private void OnCollisionEnter2D(Collision2D collision) { Destroy(gameObject); }
private void OnCollisionEnter2D(Collision2D collision) { GamePlayManager.PlayerScore(collision.gameObject); // Player has collected an apple }
void OnCollisionEnter2D(Collision2D col) { Collision(col); }
void OnCollisionEnter2D(Collision2D collision) { Debug.Log("Collided with someone"); }
private void OnCollisionStay2D(Collision2D collision) { //敌人坦克和其他物体触发碰撞后,则随机改变方向 //Debug.Log("敌人坦克撞到障碍,改变运行方向"); ResetTimeValChangeDirection(); }
public virtual void Collision(Collision2D col) { }
void OnCollisionEnter2D(Collision2D other) { }
void OnCollisionStay2D(Collision2D col) { OnCollisionEnter2D(col); }
void OnCollisionEnter2D(Collision2D col) { // Checks if player is on the ground, if so then the player is grounded, can jump again, cannot double jump and animations are changed if (col.gameObject.tag == "Gnd" && plyr.falling == false) { plyr.grounded = true; jump.candoublejump = false; jump.jumpcurrentframe = 0; jump.candjumpcurrentframe = 0; jump.djumpcurrentframe = 0; jump.djumped = false; block.mayoair = false; anim.SetBool("Jumping", false); anim.SetBool("Double Jumping", false); anim.SetBool("Falling", false); anim.SetBool("Hurt", false); } /*if(col.gameObject.tag == "Cln" && plyr.falling == false && plyr.gravityflip == true) { * plyr.grounded = true; * jump.candoublejump = false; * jump.jumpcurrentframe = 0; * jump.candjumpcurrentframe = 0; * jump.djumpcurrentframe = 0; * jump.djumped = false; * block.mayoair = false; * anim.SetBool("Jumping", false); * anim.SetBool("Double Jumping", false); * anim.SetBool("Falling", false); * anim.SetBool("Hurt", false); * }*/ // If the player collides with a wall while falling, then they are not grounded, slamming or rotating if ((col.gameObject.tag == "Lwl" || col.gameObject.tag == "Rwl") && plyr.falling == true) { plyr.grounded = false; slam.slamming = false; rb.constraints = RigidbodyConstraints2D.FreezeRotation; } // If the player collides with a wall on there left, then they cannot move in that direction if (col.gameObject.tag == "Lwl") { move.canwalkleft = false; if (col.gameObject.tag == "Gnd" && plyr.soaped == false) { rb.velocity = new Vector2(0, 0); } } // If the player collides with a wall on there right, then they cannot move in that direction if (col.gameObject.tag == "Rwl") { move.canwalkright = false; if (col.gameObject.tag == "Gnd" && plyr.soaped == false) { rb.velocity = new Vector2(0, 0); } } // If the player goes through a wall somehow, the box collider will be disabled so they can escape if (col.gameObject.tag == "Zip") { bx.enabled = false; } }
void OnCollisionEnter2D(Collision2D coll) { Destroy(coll.gameObject); CubeSpawner.numCubesEaten += 1; }
void SpawnNotesParticles(Collision2D info) { var collisionPoint2D = info.GetContact(0).point; var pos = new Vector3(collisionPoint2D.x, collisionPoint2D.y, 0); var go = Instantiate(_particlesNotesPrefab, pos, Quaternion.identity, null); }
void OnCollisionExit2D(Collision2D coll) { hasRotated = false; }
private void OnCollisionEnter2D(Collision2D collision) { Submarine hit = collision.gameObject.GetComponent<Submarine>(); hit.TakeDamage(5.0f); }
private void OnCollisionEnter2D(Collision2D collision) { }
void OnCollisionEnter2D(Collision2D collision) { ChangeDirection(); }
public void OnCollisionEnter2D(Collision2D collision) { Detonate(); Destroy(this.gameObject); return; }
public void StopAndAttack(Collision2D otherobject) { m_attack.DoDamage(otherobject); }
private void OnCollisionExit2D(Collision2D other) { other.gameObject.GetComponent <GamepadVibrate>().StopVibrations(); }
public void OnCollisionEnter2D(Collision2D collision) { StopAndAttack(collision); }
void OnCollisionEnter2D (Collision2D col) { DeconstructEffect.Generate(platforms.lastPosition); platforms.GenerateNextPlatform(Random.value > .8f); movement.Jump(); }