private void OnCollisionEnter2D( Collision2D collision ) { if ( collision.gameObject.tag == "Player" ) Attack(); else Physics2D.IgnoreCollision( this.GetComponent< Collider2D >() , collision.collider ); }
protected void enableCollision(Collider2D col) { Physics2D.IgnoreCollision(this.col, col, false); }
// Start is called before the first frame update private void Start() { Physics2D.IgnoreCollision(GetComponent <Collider2D>(), other, true); }
// Use this for initialization void Start() { playerCollider = GameObject.Find("Player").GetComponent <BoxCollider2D>(); Physics2D.IgnoreCollision(platformCollider, platformTrigger, true); }
private void Start() { Physics2D.IgnoreCollision(Bullets, GetComponent <Collider2D>()); Physics2D.IgnoreCollision(PlayerPunch, GetComponent <Collider2D>()); Physics2D.IgnoreCollision(PlayerSword, GetComponent <Collider2D>()); }
void Die() { // Player death if (gameObject.tag == "Player") { // Stops player from being able to move on death and plays death animation GetComponent <PlayerMovement>().StopPlayerMovement(); StartCoroutine(GetComponent <PlayAnimations>().Kill()); // Removes any weapons the host may have foreach (Transform child in gameObject.transform) { Destroy(child); } // Triggers game restart gameManager.EndGame(); } if (gameObject.tag == "GhostBoss") { // Take player to game over screen for the time being currentRoom.GetComponent <SimpleRoom>().SpawnExitTile(); // gameManager.TemporaryGameComplete(); } if (isBoss && gameObject.tag == "MiniBoss") { currentRoom.GetComponent <SimpleRoom>().UnlockExitTile(); gameManager.miniBossKilled = true; } if (!isDead && gameObject.name != player.tag) { isDead = true; if (TryGetComponent(out AIMovement aim)) { aim.enabled = false; } if (TryGetComponent(out GhostAttacks ga)) { ga.enabled = false; } if (TryGetComponent(out CapsuleCollider2D cc)) { Physics2D.IgnoreCollision(cc, player.GetComponent <CapsuleCollider2D>()); } if (TryGetComponent(out BoxCollider2D bc)) { Physics2D.IgnoreCollision(bc, player.GetComponent <CapsuleCollider2D>()); } //Add player XP if (isBoss) { GameObject.Find("GameManager").GetComponent <GameManager>().AddXP(XP + 500); } else { GameObject.Find("GameManager").GetComponent <GameManager>().AddXP(XP); } //Play death animation StartCoroutine(GetComponent <PlayAnimations>().Kill()); //Drop loot if (!isBoss) { // Need to add boss drops GetComponent <DropLoot>().SpawnLoot(); } } }
// Start is called before the first frame update void Start() { Physics2D.IgnoreCollision(rey.transform.GetComponent <Collider2D>(), torre.transform.GetComponent <Collider2D>(), true); // Physics2D.IgnoreCollision(rey.transform.GetComponent<Collider2D>(), torre.transform.GetComponent<Collider2D>()); }
/*************************************************************************************************************** * makeDamageBoxApper() is called from animator controller. It instantiates a damage box that could collider with * player's rigidbody. ****************************************************************************************************************/ private void makeDamageBoxApper() { damage = (GameObject)Instantiate(DamageBox, new Vector3(playerPos.x + adjustment.x, playerPos.y + adjustment.y, playerPos.z), transform.rotation); damage.GetComponent <EnemyDamage>().Char = GetComponent <Character>(); Physics2D.IgnoreCollision(damage.GetComponent <Collider2D>(), GetComponent <Collider2D>()); }
// Use this for initialization void Start() { Physics2D.IgnoreCollision(Player.GetComponent <Collider2D> (), GetComponent <Collider2D> (), true); }
// Update is called once per frame void Update() { Enemypos = transform.position; if (groundCheck) { isGrounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, isGroundLayer); } //if the player is on the ground // rb.velocity = new Vector2(-speed, rb.velocity.y); if (isGrounded) { anim.SetBool("jump", false); if (jumps > 0) { shield = true; anim.SetBool("attack", false); rb.velocity = new Vector2(0, jumpForce); jumps -= 1; } else if (shots > 0 && jumps <= 0) { shield = false; anim.SetBool("attack", false); rb.velocity = new Vector2(0, 0); if (projectile && projectileSpawnPoint) { if (nextShot > 0) { nextShot -= 1; anim.SetBool("attack", true); } if (nextShot <= 0) { Rigidbody2D temp = Instantiate(projectile, projectileSpawnPoint.position, projectileSpawnPoint.rotation); Physics2D.IgnoreCollision(GetComponent <Collider2D>(), temp.GetComponent <Collider2D>(), true); temp.AddForce(-projectileSpawnPoint.right * projectileForce, ForceMode2D.Impulse); shots -= 1; nextShot = 80; } } } else if (shots <= 0 && jumps <= 0) { rb.velocity = new Vector2(0, 0); jumps = Random.Range(1, 10); shots = 4; } if (health < 1) { Destroy(gameObject); } } if (!isGrounded) { anim.SetBool("jump", true); rb.velocity += Vector2.up * Physics2D.gravity.y * (fallSpeed - 1) * Time.deltaTime; } }
public void OnCollisionEnter2D(Collision2D other) { // print(other.gameObject.tag); //Physics2D.IgnoreCollision(thumbStop.GetComponent<Collider2D>(), GetComponent<Collider2D>()); if (other.gameObject.tag == "key") { gameManager.levelScore += 1000; GameControl.control.key = true; Destroy(other.gameObject); } if (other.gameObject.tag == "timeStop") { gameManager.levelScore += 1000; AdventureBag.aBag.times++; Destroy(other.gameObject); } if (other.gameObject.tag == "life") { gameManager.levelScore += 1000; GameControl.control.lives++; Destroy(other.gameObject); } if (other.gameObject.tag == "zoom") { gameManager.levelScore += 1000; AdventureBag.aBag.zooms++; Destroy(other.gameObject); } if (other.gameObject.tag == "fly") { gameManager.levelScore += 1000; AdventureBag.aBag.flys++; Destroy(other.gameObject); } if (other.gameObject.tag == "ScoreAdder") { gameManager.levelScore += 1000; Destroy(other.gameObject); } if (other.gameObject.tag == "Chickie") { // print("chickie"); gameManager.levelScore *= 2; gameManager.Scoretextmultiplier.gameObject.SetActive(true); Invoke("hm", 2); Destroy(other.gameObject); } if (other.gameObject.tag == "lock") { if (GameControl.control.key) { Destroy(other.gameObject.transform.parent.gameObject); } } if (other.gameObject.tag == "wall" && !flyin) { if (other.contacts[0].otherCollider.transform.gameObject.name == "trysmt") { Physics2D.IgnoreCollision(thumbStop.GetComponentInChildren <Collider2D>(), other.gameObject.GetComponent <Collider2D>()); // print("Frantic"); GetComponent <Animator>().SetBool("Frantic", true); } else { playerclicked = false; GetComponent <Animator>().SetBool("Dizzy", true); transform.Translate(normalizeToDirection(transform.position, other.collider) * 0.05f); } } if (other.gameObject.tag == ("Respawn")) { if (other.contacts[0].otherCollider.transform.gameObject.name == "trysmt") { Physics2D.IgnoreCollision(thumbStop.GetComponentInChildren <Collider2D>(), other.gameObject.GetComponent <Collider2D>()); } } if (other.gameObject.tag == ("Finish")) { // print("hit"); //Time.timeScale = 0f; //StartCoroutine(gameManager.screenPulse()); if (gameManager.thisLevel.number % 5 != 4) { slowdown = false; GameManager.gameSpeed = 0; gameManager.gobackyn = false; if (other.contacts[0].otherCollider.transform.gameObject.name == "trysmt") { Physics2D.IgnoreCollision(thumbStop.GetComponentInChildren <Collider2D>(), other.gameObject.GetComponent <Collider2D>()); gameManager.Finished(GameManager.FinishState.ALIVE, gameManager.Win); } } else if (gameManager.thisLevel.number % 5 == 4 && GameControl.control.key == true) { slowdown = false; GameManager.gameSpeed = 0; GameControl.control.key = false; gameManager.gobackyn = false; if (other.contacts[0].otherCollider.transform.gameObject.name == "trysmt") { Physics2D.IgnoreCollision(thumbStop.GetComponentInChildren <Collider2D>(), other.gameObject.GetComponent <Collider2D>()); gameManager.Finished(GameManager.FinishState.ALIVE, gameManager.PhaseComplete); } } else { transform.Translate((transform.position - other.transform.position) * 0.2f); } } if (other.gameObject.tag == "laser" || (other.gameObject.tag == "spikes" && !flyin)) { if (other.contacts[0].otherCollider.transform.gameObject.name == "trysmt") { Physics2D.IgnoreCollision(thumbStop.GetComponentInChildren <Collider2D>(), other.gameObject.GetComponent <Collider2D>()); // print("Frantic"); GetComponent <Animator>().SetBool("Frantic", true); } else { playerclicked = false; if (!isdamaged) { //Time.timeScale = (0); isdamaged = true; playerclicked = false; slowdown = false; GameManager.gameSpeed = 0; gameManager.maxGameSpeed = 0; //Time.timeScale = 0f; GetComponent <Animator>().SetBool("Dead", true); // StartCoroutine(gameManager.screenShake()); if (GameControl.control.lives <= 0) { GameControl.control.LevelNumber = 0; // Physics.IgnoreCollision(other.gameObject.GetComponent<Collider>(), GetComponent<Collider>()); Invoke("dotheInvoke", 1); Physics2D.IgnoreCollision(other.gameObject.GetComponent <Collider2D>(), GetComponent <Collider2D>()); // GameControl.control.lives = 3; } else { Invoke("dotheInvoke2", 1); // Physics.IgnoreCollision(other.gameObject.GetComponent<Collider>(), GetComponent<Collider>()); gameManager.gobackyn = true; //GameControl.control.seedToLoad = gameManager.thisSeed; // reloadLevel(); } } } } else { GetComponent <Animator>().SetBool("Frantic", false); } }
// Start is called before the first frame update void Start() { numberOfHits = 3; Physics2D.IgnoreCollision(champion.GetComponent <Collider2D>(), GetComponent <Collider2D>()); }
// Use this for initialization void Start() { Physics2D.IgnoreCollision(platformCollider, platformTrigger, true); }
void Start() { playerCollider = Player.Instance.GetComponent <BoxCollider2D>(); Physics2D.IgnoreCollision(collisionPlatform, triggerPlatform, true); Physics2D.IgnoreCollision(collisionPlatform, GameObject.FindObjectOfType <Boss>().GetComponent <BoxCollider2D>(), true); }
// Update is called once per frame void Update() { if (alive) { //Set isOnScreen appropriately if (Mathf.Abs(transform.position.x) < 8 && Mathf.Abs(transform.position.y) < 5) { isOnScreen = true; } //warning symbols //Draw ray from enemy to player Debug.DrawLine(transform.position, playerTransform.position); //warningSymbol = transform.GetChild(0).gameObject; //Only draw warning symbol if enemy is not visible, else destroy it if (isOnScreen == false) { //Calculate which side the line intersects with //Slope of line float enemyPlayerLineSlope = (transform.position.y - playerTransform.position.y) / (transform.position.x - playerTransform.position.x); Vector2 enemyPosition = new Vector2(transform.position.x, transform.position.y); Vector2 playerPosition = new Vector2(playerTransform.position.x, playerTransform.position.y); //print(enemyPlayerLineSlope * 4.5); //Rectangle is 15.6 wide, 9 tall, centered at 0,0 (so half-values are 7.8 and 4.5) if (-4.5 <= enemyPlayerLineSlope * 7.8 && enemyPlayerLineSlope * 7.8 <= 4.5) { //Left or right side? if (transform.position.x > playerTransform.position.x) { //right side warningSymbol.transform.position = LineIntersection(enemyPosition, playerPosition, new Vector2(7.8f, 4.5f), new Vector2(7.8f, -4.5f)); } else if (transform.position.x < playerTransform.position.x) { //left side warningSymbol.transform.position = LineIntersection(enemyPosition, playerPosition, new Vector2(-7.8f, 4.5f), new Vector2(-7.8f, -4.5f)); } else { print("uh oh"); } } else { //Top or bottom edge? if (transform.position.y > playerTransform.position.y) { //top side warningSymbol.transform.position = LineIntersection(enemyPosition, playerPosition, new Vector2(-7.8f, 4.5f), new Vector2(7.8f, 4.5f)); } else { //bottom side warningSymbol.transform.position = LineIntersection(enemyPosition, playerPosition, new Vector2(-7.8f, -4.5f), new Vector2(7.8f, -4.5f)); } } if (warningSymbol.transform.position == new Vector3(0, 0, 0)) { warningSymbol.GetComponent <SpriteRenderer>().enabled = false; } } else if (isOnScreen) { Destroy(warningSymbol); } // float z = transform.rotation.eulerAngles.z; transform.LookAt(GameObject.FindGameObjectWithTag("Player").transform.position); float playerX = GameObject.FindGameObjectWithTag("Player").transform.position.x; float playerY = GameObject.FindGameObjectWithTag("Player").transform.position.y; transform.rotation = Quaternion.Euler(0, 0, Mathf.Atan2(playerY - transform.position.y, playerX - transform.position.x)); transform.Translate(Vector3.Normalize(GameObject.FindGameObjectWithTag("Player").transform.position - transform.position) * Time.deltaTime * speed); if (health <= 0) { death(); } } if (transform.position.x > -8 && transform.position.x < 8 && transform.position.y < 4 && transform.position.y > -4) { foreach (GameObject g in GameObject.FindGameObjectsWithTag("Wall")) { Physics2D.IgnoreCollision(g.GetComponent <Collider2D>(), GetComponent <Collider2D>(), false); } } }
void LateUpdate() { UpdateHealth(); if (!Attacking && !hit) { float movement = Input.GetAxis("Horizontal"); Animation(movement); if (Input.GetKeyDown(KeyCode.X)) { if (!Grounded) { if (!airAttack) { JumpAttackAnimation(); airAttack = true; animator.SetBool("airAttack", true); rb.velocity = new Vector2(JumpAttackSpeed * movement, rb.velocity.y / 2); } } else { AttackAnimation(); } } if (Grounded) { rb.velocity = new Vector3(movement * MovementSpeed, rb.velocity.y); } else { rb.velocity = new Vector3((movement * MovementSpeed), rb.velocity.y); } if (Input.GetKeyUp(KeyCode.Z) && !Grounded) { if (Falling && !airAttack) { rb.velocity = new Vector2(0, rb.velocity.y / 2); Falling = false; } } } else { if (attackTimeCounter > 0) { attackTimeCounter -= Time.deltaTime; } else { Attacking = false; animator.SetBool("attacking", false); } } if (knockBackTimeCounter > 0) { knockBackTimeCounter -= Time.deltaTime; } else { animator.SetBool("hit", false); hit = false; } if (postHitInvinvibilityCounter > 0) { postHitInvinvibilityCounter -= Time.deltaTime; GetComponent <Renderer>().enabled = !GetComponent <Renderer>().enabled; } else { invincible = false; GetComponent <Renderer>().enabled = true; Physics2D.IgnoreCollision(GetComponent <Collider2D>(), lastEnemyCollider, false); } }
// Use this for initialization void Start() { bc2d = GetComponent <Collider2D>(); Physics2D.IgnoreCollision(ball.GetComponent <Collider2D>(), bc2d); }
//Initialise void Start() { startPoint = this.gameObject.transform.position; shooter = GameObject.FindGameObjectWithTag(shooterTag); Physics2D.IgnoreCollision(this.gameObject.GetComponent <Collider2D>(), shooter.gameObject.GetComponent <Collider2D>()); }
private void OnTriggerExit2D(Collider2D collider) { Physics2D.IgnoreCollision(collider, GetComponent <Collider2D>()); }
public void Init() { Physics2D.IgnoreCollision(l_shootingPlayer, GetComponent <Collider2D>()); }
protected virtual void Start() { Collider2D playerCollider = PlayerController.Instance.gameObject.GetComponent <Collider2D>(); Physics2D.IgnoreCollision(GetComponent <Collider2D>(), playerCollider, true); }
// Use this for initialization void Start() { GameObject wholeCat = GameObject.FindGameObjectWithTag("WholeCat"); Physics2D.IgnoreCollision(this.GetComponent <Collider2D>(), wholeCat.GetComponent <Collider2D>()); }
private void Awake() { m_rigidbody2D = this.GetComponent <Rigidbody2D>(); Physics2D.IgnoreCollision(this.GetComponent <Collider2D>(), GameObject.FindGameObjectWithTag("Gun").GetComponent <Collider2D>()); }
private IEnumerator shootProjectile() { shootstamp = Time.time + timeBtwShots; doodooingSomething = true; Vector2 direction; whichAttack = Random.Range(0, whichAttackRange); switch (whichAttack) { case 3: state = State.fire; yield return(new WaitForSeconds(1f)); for (int i = 0; i < 5; i++) { lavaAttack.Play(); lockedOn = new Vector2(wizard.transform.position.x, -6.5f); yield return(new WaitForSeconds(0.3f)); Projectile bullet = Instantiate(lavaBossAttack, lockedOn, transform.rotation).GetComponent <Projectile>(); } break; case 2: for (int i = 0; i < 2; i++) { batAttack.Play(); state = State.water; direction = wizard.transform.position - transform.position; Projectile bullet = Instantiate(batBossAttack, transform.position, transform.rotation).GetComponent <Projectile>(); bullet.GetComponent <Rigidbody2D>().velocity = direction * 3f; float angle = Mathf.Atan2(bullet.GetComponent <Rigidbody2D>().velocity.y, bullet.GetComponent <Rigidbody2D>().velocity.x) * Mathf.Rad2Deg; bullet.transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward); yield return(new WaitForSeconds(0.6f)); } break; case 1: for (int i = 0; i < 3; i++) { plantAttack.Play(); state = State.plant; direction = wizard.transform.position - transform.position; Projectile bullet = Instantiate(plantBossAttack, transform.position, transform.rotation).GetComponent <Projectile>(); bullet.GetComponent <Rigidbody2D>().velocity = direction * 2f; float angle = Mathf.Atan2(bullet.GetComponent <Rigidbody2D>().velocity.y, bullet.GetComponent <Rigidbody2D>().velocity.x) * Mathf.Rad2Deg; bullet.transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward); yield return(new WaitForSeconds(0.3f)); } break; default: for (int i = 0; i < 1; i++) { state = State.basic; direction = wizard.transform.position - transform.position; Projectile bullet = Instantiate(projectile, transform.position, transform.rotation).GetComponent <Projectile>(); Physics2D.IgnoreCollision(bullet.gameObject.GetComponent <BoxCollider2D>(), coll); bullet.GetComponent <Rigidbody2D>().velocity = direction * 2f; float angle = Mathf.Atan2(bullet.GetComponent <Rigidbody2D>().velocity.y, bullet.GetComponent <Rigidbody2D>().velocity.x) * Mathf.Rad2Deg; bullet.transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward); yield return(new WaitForSeconds(0.2f)); } break; } doodooingSomething = false; }
private void Start() { Physics2D.IgnoreCollision(GetComponent <Collider2D>(), midWall); Physics2D.IgnoreCollision(GetComponent <Collider2D>(), leftBorder); Physics2D.IgnoreCollision(GetComponent <Collider2D>(), rightBorder); }
// Update is called once per frame void Update() { setDirection(); if (inView && state != State.hurt && state != State.dead) { if (health <= 10f && angryMode && !angrierMode) { angrierMode = true; health = 20f; timeBtwTP = 3f; numberOfTri = 2; } if (health <= 10f && !angryMode) { angryMode = true; health = 20f; timeBtwShots = 4f; whichAttackRange = 4; moveSpeed = 8f; } if (Time.time >= tristamp && !doodooingSomething) { StartCoroutine(snare()); } else if (Time.time >= sumstamp && !doodooingSomething && angryMode) { StartCoroutine(summonZombies()); } else if (Time.time >= tpstamp && !doodooingSomething) { StartCoroutine(teleport()); } else if (Time.time >= shootstamp && !doodooingSomething) { StartCoroutine(shootProjectile()); } else if (!doodooingSomething) { movement(); } } healthSlider.value = health; if (health <= 0) { state = State.dead; witchisdead = true; doodooingSomething = true; Physics2D.IgnoreCollision(wizard.gameObject.GetComponent <BoxCollider2D>(), coll); Physics2D.IgnoreCollision(wizard.gameObject.GetComponent <CircleCollider2D>(), coll); Physics2D.IgnoreCollision(toDisable.GetComponent <CircleCollider2D>(), coll); DestroyAllZombies(); StartCoroutine(ifDead()); } if (wizard.GetComponent <WizardController>().state == WizardController.State.dead) { inView = false; state = State.teleport; transform.position = spawn; } anim.SetInteger("state", (int)state); StartCoroutine(AnimationState()); }
protected void disableCollision(Collider2D col) { Physics2D.IgnoreCollision(this.col, col); }
public void CharacterSoldier(int index) { GameObject Role = PhotonNetwork.Instantiate(StaticVar.Roles[GetRole + index], CreateRolePoint2.position, new Quaternion(0, 90, 0, 0), 0); //GameObject Role = PhotonNetwork.Instantiate(StaticVar.Roles[index], CreateRolePoint2.position, new Quaternion(0, 90, 0, 0), 0); //給標籤,用來分辨是否是自己的 Role.tag = (pv.IsMine) ? "P1" : "P2"; pv.RPC("AddTag", RpcTarget.All, Role.tag, Role.GetComponent <PhotonView>().ViewID); GameObject.Find("MainTower").tag = Role.tag; GameObject.Find("SideTower").tag = (Role.tag == "P2") ? "P1" : "P2"; //忽略自己 Physics2D.IgnoreCollision(Role.GetComponent <Collider2D>(), Role.GetComponent <Collider2D>()); Physics2D.showColliderContacts = true; //忽略己方(P1或P2) GameObject[] P = GameObject.FindGameObjectsWithTag(Role.tag); foreach (GameObject g in P) { Physics2D.IgnoreCollision(Role.GetComponent <Collider2D>(), g.GetComponent <Collider2D>()); } pv.RPC("RPCIgnoreMySildCollider", RpcTarget.All, false, Role.GetComponent <PhotonView>().ViewID); ////剛生成的時候,先忽略所遇到的塔 Physics2D.IgnoreCollision(Role.GetComponent <Collider2D>(), GameObject.Find("MainTower").GetComponent <Collider2D>()); //自己畫面 Physics2D.IgnoreCollision(Role.GetComponent <Collider2D>(), GameObject.Find("SideTower").GetComponent <Collider2D>()); //自己畫面 //pv.RPC("RPCIgnoreCollider", RpcTarget.All, true, Role.GetComponent<PhotonView>().ViewID,""); //對方畫面,RPC的自己 Role.transform.position = CreateRolePoint1.position; Role.transform.rotation = CreateRolePoint1.rotation; ////移動位置後,將對方塔打開,忽略自己塔(不要忽略對方塔)-自己的畫面 //Physics2D.IgnoreCollision(Role.GetComponent<Collider2D>(), GameObject.Find("SideTower").GetComponent<Collider2D>(), false); //對方畫面,RPC的自己,不要忽略對方主塔 //Debug.Log(Role.tag + "--------------------------------------------->" + pv.IsMine); //if (Role.tag == "P1") //{ // Physics2D.IgnoreCollision(Role.GetComponent<Collider2D>(), GameObject.Find("MainTower").GetComponent<Collider2D>()); //} if (pv.IsMine) { pv.RPC("RPCIgnoreCollider", RpcTarget.All, false, Role.GetComponent <PhotonView>().ViewID, "MainTower"); if (Role.tag == "P1") { Physics2D.IgnoreCollision(Role.GetComponent <Collider2D>(), GameObject.Find("SideTower").GetComponent <Collider2D>(), false); } //Physics2D.IgnoreCollision(Role.GetComponent<Collider2D>(), GameObject.Find("MainTower").GetComponent<Collider2D>(), false); } else { //pv.RPC("RPCIgnoreCollider", RpcTarget.All, false, Role.GetComponent<PhotonView>().ViewID, "SideTower"); if (Role.tag == "P2") { Physics2D.IgnoreCollision(Role.GetComponent <Collider2D>(), GameObject.Find("SideTower").GetComponent <Collider2D>(), false); } //Physics2D.IgnoreCollision(Role.GetComponent<Collider2D>(), GameObject.Find("SideTower").GetComponent<Collider2D>(), false); } }
// Start is called before the first frame update void Start() { gm = GameObject.FindWithTag("GM").GetComponent <GM>(); Physics2D.IgnoreCollision(powerUp.GetComponent <Collider2D>(), GetComponent <Collider2D>()); }
// Update is called once per frame void Update() { if (finalKey2 != null) { Physics2D.IgnoreCollision(finalKey2.GetComponent <Collider2D> (), this.GetComponent <Collider2D> ()); } Vector3 enemyPos = new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z); Vector3 playerPos = new Vector3(player.transform.position.x, player.transform.position.y, player.transform.position.z); if (Vector3.Distance(this.transform.position, player.transform.position) < 400f) { shotCounter += Time.deltaTime; spriteTimer += Time.deltaTime * 2; enemyPos.y -= moveAmount * Time.deltaTime; moveTimer += Time.deltaTime; if (moveTimer >= 1) { moveAmount = -moveAmount; moveTimer = 0; } if (enemyPos.x < playerPos.x) { if ((int)spriteTimer % 2 == 1) { this.GetComponent <SpriteRenderer> ().sprite = standingRight; } if ((int)spriteTimer % 2 == 0) { this.GetComponent <SpriteRenderer> ().sprite = flyingRight; } } if (enemyPos.x > playerPos.x) { if ((int)spriteTimer % 2 == 1) { this.GetComponent <SpriteRenderer> ().sprite = standingLeft; } if ((int)spriteTimer % 2 == 0) { this.GetComponent <SpriteRenderer> ().sprite = flyingLeft; } } if (shotCounter >= 1.5f) { timeToSpawnMinions = true; shotCounter = 0.0f; } if (timeToSpawnMinions == true) { GameObject specialLavaClone = (GameObject)Instantiate(specialLava); timeToSpawnMinions = false; Vector3 clonePos = new Vector3(specialLavaClone.transform.position.x, specialLavaClone.transform.position.y, specialLavaClone.transform.position.z); clonePos.x = enemyPos.x; clonePos.y = enemyPos.y; specialLavaClone.transform.position = clonePos; Physics2D.IgnoreCollision(this.GetComponent <Collider2D> (), specialLavaClone.GetComponent <Collider2D> ()); } } if (health <= 0) { Destroy(this.gameObject); } if (GameObject.Find("transitionStart1").GetComponent <transitionStartManager> ().playerTouchedTransition == true) { Destroy(this.gameObject); } if (GameObject.Find("transitionStart2").GetComponent <transitionStartManager> ().playerTouchedTransition == true) { Destroy(this.gameObject); } if (GameObject.Find("transitionStart3").GetComponent <transitionStartManager> ().playerTouchedTransition == true) { Destroy(this.gameObject); } if (GameObject.Find("transitionStart4").GetComponent <transitionStartManager> ().playerTouchedTransition == true) { Destroy(this.gameObject); } if (GameObject.Find("transitionStart5").GetComponent <lockedTransitionStartManager> ().playerTouchedTransition == true) { Destroy(this.gameObject); } if (GameObject.Find("transitionStart5").GetComponent <lockedTransitionStartManager> ().playerTouchedTransition == true) { Destroy(this.gameObject); } if (GameObject.Find("transitionStart6").GetComponent <transitionStartManager> ().playerTouchedTransition == true) { Destroy(this.gameObject); } if (GameObject.Find("transitionStart7").GetComponent <transitionStartManager> ().playerTouchedTransition == true) { Destroy(this.gameObject); } if (GameObject.Find("transitionStart8").GetComponent <transitionStartManager> ().playerTouchedTransition == true) { Destroy(this.gameObject); } if (GameObject.Find("transitionStart9").GetComponent <transitionStartManager> ().playerTouchedTransition == true) { Destroy(this.gameObject); } if (GameObject.Find("transitionStart10").GetComponent <lockedTransitionStartManager> ().playerTouchedTransition == true) { Destroy(this.gameObject); } if (GameObject.Find("transitionStart11").GetComponent <transitionStartManager> ().playerTouchedTransition == true) { Destroy(this.gameObject); } if (GameObject.Find("transitionStart12").GetComponent <transitionStartManager> ().playerTouchedTransition == true) { Destroy(this.gameObject); } if (GameObject.Find("transitionStart13").GetComponent <transitionStartManager> ().playerTouchedTransition == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().RM1Checkpoint == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().RM2CheckpointL == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().RM2CheckpointR == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().RM4CheckpointL == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().RM4CheckpointR == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().RM6CheckpointL == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().RM6CheckpointR == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().RM7CheckpointL == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().RM7CheckpointR == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().RM8CheckpointL == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().RM8CheckpointR == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().RM9CheckpointL == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().RM9CheckpointR == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().RM10CheckpointL == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().RM10CheckpointR == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().RM11CheckpointL == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().Boss1CheckpointL == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().Boss2CheckpointL == true) { Destroy(this.gameObject); } if (GameObject.Find("Player").GetComponent <playerMove> ().Boss3CheckpointL == true) { Destroy(this.gameObject); } this.transform.position = enemyPos; }