void SwordState() { if (Input.GetMouseButtonDown(0) && timeToAttack <= 0) { swordAnim.SetBool("IsAttacking", true); timeToAttack = timeToAttackValue; Collider[] enemiesToDmg = Physics.OverlapSphere(attackPos.position, attackRange, whatIsEnemies); for (int i = 0; i < enemiesToDmg.Length; i++) { // collider.gameObject ==> since this collider is from gameobject GameplayStatics.DealDamage(enemiesToDmg[i].gameObject, slashDmg); Debug.Log("HIt"); if (enemiesToDmg[i].gameObject.tag == "LumberJack") // check if the enemy is LumberJack then we can do jumpbuff; { timeToJumpBuff = 0; } } } else { swordAnim.SetBool("IsAttacking", false); timeToAttack -= Time.deltaTime; } }
//void OnTriggerEnter(Collider other) //{ // if(other.tag == "Player" || other.name == "Player") // { // GameplayStatics.DealDamage(other.gameObject, 1); // } //} void OnCollisionEnter(Collision other) { if (other.collider.tag == "Player" || other.collider.name == "Player") { GameplayStatics.DealDamage(other.gameObject, 1); } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Player" && !GameManager.Instance.isImmortality) { GameplayStatics.DealDamage(other.gameObject, 1); } }
private void OnTriggerEnter(Collider other) { // if other is ColoredWalls if (other.CompareTag("Walls")) { // ColoredWalls Ref (this gameobject is Cylinder) MeshRenderer coloredWallsColor = other.gameObject.GetComponent <MeshRenderer>(); nextTower = 1 + other.gameObject.transform.parent.parent.GetComponentInParent <TowerObjectPulling>().TowerNumber; // if player color is the same as one of the walls that collide OR player is immortal if (currentColor.material.name == coloredWallsColor.material.name || GameManager.Instance.isImmortality) { if (totalTriggered == 0) // AVOID DOUBLE TRIGGER { totalTriggered++; StartCoroutine(delayWallTrigger(0.15f)); // delay it, to avoid getting killed from changing color while still inside the walls } } else { GameplayStatics.DealDamage(gameObject, 1); } } // For Coins and Diamonds if (other.CompareTag("Coins")) { IncreaseCoins(other.gameObject); } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag != "Player") { return; } GameplayStatics.DealDamage(collision.gameObject, 1); }
private void OnTriggerEnter(Collider other) { //make sure we're not colliding with the player shooting the projectile if (other.gameObject == Owner) { return; } if (Application.isEditor)// are we running it inside the editor { //Debug.Log("Projectile collided with " + other.name); } if (other.gameObject.GetComponent <EnemyHealth>()) // that way it will not call this if it's not enemy, perfect for increasing combo cooldown { if (gameObject.name == "MinigunBullet(Clone)") // if the projectile is from MinigunBullet(Clone)(Since we spawn it), then change damage { GameplayStatics.DealDamage(other.gameObject, 0.4f); Debug.Log("MACHINE GUN"); } else { Debug.Log("NOT"); // damage hit enemy or other object if they have HealthComponent GameplayStatics.DealDamage(other.gameObject, 1); } if (ComboKill.currentCombo != 1) // only increase cooldown if current combo is not 1 { ComboKill.cooldown = ComboKill.cooldown + 0.1f; // increase combo cooldown } } // instantiating effects SpawnEffects(); //if(other.name != "BaseProjectile(Clone)") // note, forgot to use layer zzz //{ not going to delete as this will show how to check clone prefab // Destroy(gameObject); //} Destroy(gameObject); }
void AttackState() { GameplayStatics.DealDamage(Target, impactDamage); // damage to player (player, 1) GameplayStatics.DealDamage(gameObject, 100); // damage to self/enemy (enemy, 100) Destroy(gameObject); }