void OnTriggerExit2D(Collider2D collider) { if (this.actionsInRange.Contains (collider.GetComponentInChildren<IAction> ())) { collider.GetComponentInChildren<IAction> ().Finished (); this.actionsInRange.Remove (collider.GetComponentInChildren<IAction> ()); } }
void OnTriggerEnter2D(Collider2D col) { Debug.Log ("当たった:" + col.GetComponentInChildren<Text>().text); if (NONE_PANEL == col.GetComponentInChildren<Text> ().text) { KeepPos = col.GetComponent<RectTransform>().position; } }
void OnTriggerEnter2D(Collider2D other){ if(other.CompareTag("Player")){ other.GetComponentInChildren<Rigidbody2D>().velocity = new Vector2(0f,0f); other.GetComponent<CharacterControllerScript>().canMove(false); other.GetComponent<CharacterControllerScript>().fantasyArmorIdle.SetActive(true); other.GetComponent<CharacterControllerScript>().fantasyArmorWalking.SetActive(false); other.GetComponentInChildren<Animator>().Play("kidSmile"); doppleganger.GetComponent<Animator>().Play ("kidSmile"); credits.SetActive(true); } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.name == "Enemy"||other.gameObject.name=="Enemy(Clone)") { other.GetComponent<PlayerStats>().ChangeHealth(-(damage)); other.GetComponentInChildren<ParticleSystem>().Emit (10); } }
private void OnTriggerEnter2D(Collider2D collider2d) { Rigidbody2D body = collider2d.GetComponent<Rigidbody2D>(); if(!body) body = collider2d.GetComponentInChildren<Rigidbody2D>(); if(!body) return; body.drag = drag; body.fixedAngle = true; body.gameObject.AddComponent<LateDestroyerComponent>(); BoxCollider2D boxCollider2d = body.GetComponent<BoxCollider2D>(); if(boxCollider2d) boxCollider2d.isTrigger = true; body.tag = "Untagged"; foreach(Transform child in body.transform) GameObject.Destroy(child.gameObject); if(GameObject.FindGameObjectsWithTag("Crate").Length < 5) GameObject.FindObjectOfType<CrateSpawner>().spawnCrate(); GameObject splash = GameObject.Instantiate(splashSystem); splash.transform.position = new Vector2(collider2d.transform.position.x, yPos); splash.AddComponent<TimedDestroyer>(); }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Player" && transform.parent == null) { Item playerItem = other.GetComponentInChildren<Item> (); if (playerItem == null) { transform.parent = other.gameObject.transform; transform.localPosition = new Vector3 (0, 0.8f, 0); transform.localScale /= 1.5f; if (item.itemType == ItemType.FAKEOBJECT) { soundLauncher.CollectFake(); } else { soundLauncher.CollectTop(); if (other.gameObject.name == "Lux") MusicManager.Lux(); else MusicManager.Nox(); } } else if (playerItem.itemType == ItemType.FAKEOBJECT && item.itemType == ItemType.TOPOBJECT) { playerItem.transform.parent = null; playerItem.transform.localScale *= 1.5f; transform.parent = other.gameObject.transform; transform.localPosition = new Vector3 (0, 0.8f, 0); transform.localScale /= 1.5f; soundLauncher.CollectTop(); if (other.gameObject.name == "Lux") MusicManager.Lux(); else MusicManager.Nox(); } } /*else if (other.gameObject.tag == "Player" && transform.parent != null) other.GetComponent<PlayerControl>().Collect(item);*/ }
public void OnTriggerEnterOrExit2D(Collider2D other) { if (transform.parent.GetComponent<PlayerControl>().isDashing && other.tag == "Player"){ Item playerItem = transform.parent.GetComponentInChildren<Item> (); Item otherItem = other.GetComponentInChildren<Item> (); if(playerItem == null || otherItem == null) { } else if (playerItem.itemType == ItemType.FAKEOBJECT) { if(transform.parent.GetComponent<PlayerControl>().dashLeft) otherItem.transform.parent.gameObject.GetComponent<Rigidbody2D>().AddForce(dashLeftForce); else otherItem.transform.parent.gameObject.GetComponent<Rigidbody2D>().AddForce(dashRightForce); playerItem.transform.parent = null; playerItem.transform.localScale *= 1.5f; otherItem.transform.parent = transform.parent.transform; otherItem.transform.localPosition = new Vector3 (0, 0.8f, 0); if (otherItem.itemType == ItemType.TOPOBJECT) { if (transform.parent.name == "Lux") MusicManager.Lux(); else MusicManager.Nox(); } } else if (playerItem.itemType == ItemType.TOPOBJECT) { if(transform.parent.GetComponent<PlayerControl>().dashLeft) otherItem.transform.parent.gameObject.GetComponent<Rigidbody2D>().AddForce(dashLeftForce); else otherItem.transform.parent.gameObject.GetComponent<Rigidbody2D>().AddForce(dashRightForce); otherItem.transform.parent = null; otherItem.transform.localScale *= 1.5f; } } }
void OnTriggerStay2D(Collider2D otherObj) { if (otherObj.tag == "Player" && !otherObj.GetComponentInChildren<GroundCheckController>().touchingGround) { GetComponent<BoxCollider2D>().isTrigger = false; gameObject.tag = "Ground"; } }
void OnTriggerEnter2D(Collider2D other) { CameraScript mainCamera = other.transform.parent.GetComponent(typeof(CameraScript)) as CameraScript; mainCamera.active = false; Player player = other.GetComponentInChildren(typeof(Player)) as Player; player.StopAllCoroutines(); player.EndGame(); }
public void OnTriggerStay2D(Collider2D target) { if (target.gameObject.tag == "Enemy") { target.GetComponentInChildren<PlayerHealth> ().TakeDamage (fireballBaseDamage); Destroy (gameObject); } if (target.gameObject.tag == "Ground") { Destroy (gameObject); } if(target.gameObject.tag== "Flammable") { target.GetComponentInChildren<Torch>().activateFlammable (); Destroy (gameObject); } }
void OnTriggerEnter2D(Collider2D col) { //print(col); //checks to see if the collider belongs to a player if (col.GetComponentInParent<Health>() || col.GetComponent<GrappleScript>() || col.GetComponent<ParticleSystem>() || col.GetComponentInChildren<ParticleSystem>() || col.CompareTag("Grapple")) { if (col.GetComponent<Health>() && !respawning) SetInRespawnQueue(col.gameObject); } else { //print("Destroyyy"); Destroy(col.gameObject); } }
// compares the current colour to the collider's colour // general tool public bool compare(Collider2D collider) { ModeChange mode = collider.GetComponentInChildren<ModeChange> (); if (mode == null) { mode = collider.GetComponentInParent<ModeChange> (); return compare (mode); } else { int colour = mode.currentColour; return currentColour == colour; // if they are the same, return true } }
void OnTriggerEnter2D(Collider2D co) { Inventory inv = co.GetComponentInChildren<Inventory>() as Inventory; inv.AddItem (2); int r = Random.Range(2, 4); for (int i = 0; i < r; i++) { int item = Random.Range (3, 15); if(inv){ inv.AddItem(item); } } Destroy (this.gameObject); }
public IEnumerator RespawnPlayerCo(Collider2D player) { //Instantiate(deathParticle, player.transform.position, player.transform.rotation); player.enabled = false; player.GetComponentInChildren<Renderer>().enabled = false; player.GetComponent<Rigidbody2D>().velocity = Vector2.zero; gravityStore = player.GetComponent<Rigidbody2D>().gravityScale; player.GetComponent<Rigidbody2D>().gravityScale = 0; ScoreManager.AddPoints(-pointPenaltOnDeath); yield return new WaitForSeconds(respawnDelay); player.transform.position = checkpoint[Random.Range(0, checkpoint.Length)].transform.position; //Instantiate(lifeParticle, currentCheckpoint.transform.position, currentCheckpoint.transform.rotation); player.enabled = true; player.GetComponentInChildren<Renderer>().enabled = true; player.GetComponent<Rigidbody2D>().gravityScale = gravityStore; }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Zombie" && PorteObjectif == true) { Main.GetComponent<Timer>().GiveZPoints(); // other.Destroy(other.gameObject.Find()); } if (other.tag == "Human" && PorteObjectif == true) { other.GetComponentInChildren<Human_Handling>().FuckOffIncapacitated(); } PorteObjectif = false; }
void OnTriggerStay2D(Collider2D c) { if(c.tag.Equals(Tags.anSwitch) && Input.GetKeyDown(KeyCode.Space) && lightTurningOn == false) { this.currentLight = c.GetComponentInChildren<Light>(); this.lightTurningOn = true; if(this.currentLight.intensity == 0) StartCoroutine(TurnOn()); else StartCoroutine(TurnOff()); } }
void OnTriggerEnter2D(Collider2D other) { if(other.tag == "Player") { if(other.GetComponentInChildren<Shooting>().ammoReserve >= 120) { return; } int ammo = other.GetComponentInChildren<Shooting>().ammoReserve; ammo += (int)(ammoAmount * Random.Range(0.5f, 2)); if(ammo >= RPGelements.instance.maxAmmoPlayerCanCarry) ammo = RPGelements.instance.maxAmmoPlayerCanCarry; other.GetComponentInChildren<Shooting>().ammoReserve = ammo; other.GetComponentInChildren<Shooting>().UpdateAmmoText(); AudioSource.PlayClipAtPoint(clip, transform.position); Destroy(gameObject); } }
// Use this for initialization public void OnTriggerStay2D(Collider2D target) { if (target.gameObject.tag == "Enemy") { target.GetComponentInChildren<PlayerHealth> ().TakeDamage (arrowDamage); Destroy (gameObject); } if (target.gameObject.tag == "Ground") { Destroy (gameObject); } }
void OnTriggerEnter2D(Collider2D other) { if (Time.time < 2) return; var vehicle = other.GetComponent<Vehicle2D>(); if (vehicle) { var renderer = other.GetComponentInChildren<Renderer>(); renderer.material.color = Color.blue; Debug.LogWarning(string.Format("{2} Destroying {0} upon collision with {1}", gameObject, vehicle, Time.time)); Destroy(gameObject); } }
public void OnTriggerEnter2D(Collider2D target) { if(target.gameObject.CompareTag("Freeze")) { Debug.Log("in freeze trigger"); target.gameObject.GetComponent<objectUpAndDown>().setFrozen(2); Destroy (gameObject); } if(target.gameObject.CompareTag ("Enemy")) { //freeze enemy Debug.Log ("Hitting Enemy: " + target.gameObject.tag); target.GetComponentInChildren<EnemyMove>().setFrozen(2); Destroy (gameObject); } }
void OnTriggerEnter2D( Collider2D col ) { if ( col.transform != transform.parent ) { if ( IgnoreOtherSpheresOfInfluences && col.GetComponentInChildren<SphereOfInfluence>() != null ) { return; } var cBody = col.GetComponentInParent<CelestialBody>(); if ( cBody && cBody.Attractor != _body && cBody.Mass < _body.Mass && ( !IgnoreBodiesWithDynamicAttrChanging || !cBody.IsUsingDynamicAttractorChanging ) ) { if ( cBody.Attractor != null ) { //Check if body is already attracted by child of current _body. if ( cBody.Attractor.Attractor == _body ) { return; } } cBody.SetAttractor( _body ); } } }
public void OnTriggerEnter2D(Collider2D other) { if(!pickupOnTrigger || hasBeenActivated) { return; } Debug.Log("Trigger enter pickup"); // If the player enters trigger area, then activate PlayerController playerController = other.GetComponent<PlayerController>(); if(playerController == null) { playerController = other.GetComponentInChildren<PlayerController>(); if(playerController == null) { playerController = other.GetComponentInParent<PlayerController>(); } } if(playerController != null) { Activate(playerController); } }
public void OnTriggerEnter2D(Collider2D other) { // If the player enters trigger area, then transition to next scene PlayerController playerController = other.GetComponent<PlayerController>(); if(playerController == null) { playerController = other.GetComponentInChildren<PlayerController>(); if(playerController == null) { playerController = other.GetComponentInParent<PlayerController>(); } } if(playerController != null) { PlayerState playerState = FindObjectOfType<PlayerState>(); if(playerState != null) { Debug.Log("Begin Level Exit! Trying to save player state..."); playerState.SaveState(); } Debug.Log("Travelling to Level " + targetScene); Application.LoadLevel(targetScene); } }
public void OnTriggerEnter2D(Collider2D otherCollider) { var infiltrated1 = (otherCollider.tag == "llama_spawner" && team == "mlion"); var infiltrated2 = (otherCollider.tag == "mlion_spawner" && team == "llama"); if (otherCollider == null) return; if(infiltrated1 || infiltrated2) { completed = true; otherCollider.GetComponent<ShootAnimal>().defeated = true; completed = true; GetComponent<Animator>().SetBool("Walk", false); otherCollider.GetComponentInChildren<SpriteRenderer>().enabled = true; // raise the flag of victory GetComponent<Transform>().localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z); otherCollider.GetComponentInParent<EndGame>().updateList(otherCollider.GetComponent<GameObject>()); return; } if (GetComponent<DealDamage> () == null || otherCollider.GetComponent<DealDamage> () == null) return; if(!launched) { return; } else if (otherCollider.GetComponent<AnimalBullet>() != null && !otherCollider.GetComponent<AnimalBullet> ().launched) { return; } //if (team != otherCollider.GetComponent<AnimalBullet> ().team) { //StartCoroutine (GetComponent<DealDamage> ().Fight (otherCollider.GetComponent<Transform> ())); //StartCoroutine (otherCollider.GetComponent<DealDamage>().Fight(GetComponent<Transform>())); //} }
//Function to detect a cursor exiting from the trigger area of the Car selection icon void OnTriggerExit2D(Collider2D trigger) { if (trigger.gameObject.name != CPU.gameObject.name) { WheelImage = trigger.GetComponentInChildren<Image>(); WheelImage.color = new Color(1f, 1f, 1f, 1f); return; } isActive = false; TextColorCar = this.GetComponent<Text>(); //The car text goes back to white TextColorCar.color = Color.white; m.is_this_inside = false; //The specific cursor is not inside the icon area anymore RemoveTempCar(); }
//Function to detect a cursor entering in the trigger area of the Car icon selection void OnTriggerEnter2D(Collider2D trigger) { if (isActive) { WheelImage = trigger.GetComponentInChildren<Image>(); WheelImage.color = new Color(1f, 1f, 1f, .5f); return; } isActive = true; //If the cursor enters the icon space the icon becomes active TextColorCar = this.GetComponent<Text>(); //Get the instance of the car text and change it to yellow TextColorCar.color = Color.yellow; CPU = trigger.GetComponent<CPUController>(); m = trigger.GetComponentInParent<MoveSelector>(); //Make the object that entered the icon space (the trigger) your moveselector target (it will be one of the cursors) m.is_this_inside = true; // Change the bool variable telling if the cursor is inside the icon area t = trigger.gameObject; //Set the generic t object to the cursor/trigger old = t.transform.parent; //Save the current parent of the coin (the cursor) so it can be reassigned to the coin later ID = CPU.CoinID; AddTempCar(); if (!CPU.is_coin_cpu || CPU.CoinID == 1) { ParentPosition = t.transform.localPosition; } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag ("Key")) { key = other.GetComponentInChildren<Key> (); } }
void OnTriggerEnter2D(Collider2D col) { if (col.tag == "Player") { //Attack(); Damge(); } if (col.tag == "Bullet") { Bullet bullet = col.GetComponentInChildren<Bullet>(); if (bullet != null) { if (bullet.bulletOfObject == BulletOfObjectType.PLAYER) { bullet.KillEnemies(); //Hit(bullet.damge); } } } }
void OnTriggerEnter2D(Collider2D collider) { if (!this.actionsInRange.Contains (collider.GetComponentInChildren<IAction> ()) && collider.GetComponentInChildren<IAction> () != null) { this.actionsInRange.Add (collider.GetComponentInChildren<IAction> ()); } }
void OnCollision(Collider2D _collider) { // todo: trigger라고 맞지 않는다는 보장이 없음. 위험함. if (_collider.isTrigger) return; if (decaying) return; if (LayerHelper.Exist(collisionIgnores, _collider)) return; if (m_Ricochet) { if (! m_Ricochet.ShouldCollide(_collider)) return; if (m_Ricochet.OnCollision(_collider)) StartDecay(); } else { StartDecay(); } if (LayerHelper.Exist(collisionTargets, _collider)) { if (! activated) goto finalize; var _damageDetector = _collider.GetComponentInChildren<DamageDetector>(); var _isOwner = _damageDetector.GetInstanceID() == ownerDamageDetecterID; if (! isHitOwner && _isOwner) return; if (_damageDetector && _damageDetector.enabled) { attackData.velocity = rigidbody2D.velocity; _damageDetector.Damage(attackData); } if (postHit != null) postHit(this, _collider); // todo: server를 통해서 이루어져야합니다. if (effectHitPrf) { var _effectHit = (GameObject) Instantiate (effectHitPrf, transform.position, transform.rotation); _effectHit.transform.Translate(effectHitOffset); } } else if (LayerHelper.Exist(collisionTargets, _collider.gameObject)) { if (postBumped != null) postBumped(this, _collider); } finalize: if (postCollide != null) postCollide(this, _collider); }