//void OnDamaged(float damage, GameObject damageSource) //{ // // test if the damage source is the player // if (damageSource && damageSource.GetComponent<PlayerCharacterController>()) // { // } //} void OnDie() { Debug.Log("BigSHIt"); // spawn a particle system when dying var vfx = Instantiate(ExplotionEffect, ExplosionPosition.position, Quaternion.identity); Destroy(vfx, 5f); // area damage areaOfDamage.InflictDamageInArea(damage, transform.position, hittableLayers, k_TriggerInteraction, gameObject); //area knockback Collider[] colliders = Physics.OverlapSphere(transform.position, areaOfDamage.areaOfEffectDistance); foreach (Collider obj in colliders) { //if (obj.tag == "") ; Rigidbody rb = obj.GetComponent <Rigidbody>(); if (rb != null) { rb.AddExplosionForce(force, transform.position, areaOfDamage.areaOfEffectDistance); } } // this will call the OnDestroy function Destroy(gameObject); }
void OnHit(Vector3 point, Vector3 normal, Collider collider) { // damage if (areaOfDamage) { // area damage areaOfDamage.InflictDamageInArea(damage, point, hittableLayers, k_TriggerInteraction, m_ProjectileBase.owner); //area knockback Collider[] colliders = Physics.OverlapSphere(transform.position, areaOfDamage.areaOfEffectDistance); foreach (Collider obj in colliders) { Rigidbody rb = obj.GetComponent <Rigidbody>(); if (rb != null) { rb.AddExplosionForce(force, transform.position, areaOfDamage.areaOfEffectDistance); } } } else { // point damage Damageable damageable = collider.GetComponent <Damageable>(); if (damageable) { damageable.InflictDamage(damage, false, m_ProjectileBase.owner); } } // impact vfx if (impactVFX) { GameObject impactVFXInstance = Instantiate(impactVFX, point + (normal * impactVFXSpawnOffset), Quaternion.FromToRotation(point, normal)); if (impactVFXLifetime > 0) { Destroy(impactVFXInstance.gameObject, impactVFXLifetime); ////if can show decal //if (collider.gameObject.GetComponent<Renderer>().material != null) // collider.gameObject.GetComponent<BulletHitEffect>().Hit(point, normal, hitType); } } // impact sfx if (impactSFXClip) { AudioUtility.CreateSFX(impactSFXClip, point, AudioUtility.AudioGroups.Impact, 1f, 3f); } // Self Destruct Destroy(this.gameObject); }
void OnHit(Vector3 point, Vector3 normal, Collider collider) { // damage if (areaOfDamage) { // area damage areaOfDamage.InflictDamageInArea(damage, point, hittableLayers, k_TriggerInteraction, m_ProjectileBase.owner); } else { // point damage Damageable damageable = collider.GetComponent <Damageable>(); if (damageable) { damageable.InflictDamage(damage, false, m_ProjectileBase.owner); } // turn light on CrystalLight crystalLight = collider.GetComponent <CrystalLight>(); if (crystalLight && _notFromEnemy) { if (crystalLight.IsToggleLaser()) { crystalLight.LightOn(); } } } // impact vfx if (impactVFX) { GameObject impactVFXInstance = Instantiate(impactVFX, point + (normal * impactVFXSpawnOffset), Quaternion.LookRotation(normal)); if (impactVFXLifetime > 0) { Destroy(impactVFXInstance.gameObject, impactVFXLifetime); } } // impact sfx if (impactSFXClip) { AudioUtility.CreateSFX(impactSFXClip, point, AudioUtility.AudioGroups.Impact, 1f, 3f); } // Self Destruct Destroy(this.gameObject); }
void OnHit(Vector3 point, Vector3 normal, Collider collider) { Damageable damageable = null; // damage if (areaOfDamage) { // area damage areaOfDamage.InflictDamageInArea(damage, point, hittableLayers, k_TriggerInteraction, m_ProjectileBase.owner); } else { // point damage damageable = collider.GetComponent <Damageable>(); if (damageable) { damageable.InflictDamage(damage, false, m_ProjectileBase.owner); m_ProjectileBase.OnHit(m_Velocity); } } // impact vfx if (impactVFX) { GameObject impactVFXInstance = Instantiate(impactVFX, point + (normal * impactVFXSpawnOffset), Quaternion.LookRotation(normal)); if (impactVFXLifetime > 0) { Destroy(impactVFXInstance.gameObject, impactVFXLifetime); } } // impact sfx if (impactSFXClip) { if (damageable && damageable.damageMultiplier > 0f) { AudioUtility.CreateSFX(damageSFXClip, point, AudioUtility.AudioGroups.Impact, 0.6f, 1f, 100f, 1f); } else { AudioUtility.CreateSFX(impactSFXClip, point, AudioUtility.AudioGroups.Impact, 1f, 3f, 5f); } } // Self Destruct Destroy(this.gameObject); }
void OnHit(Vector3 point, Vector3 normal, Collider collider) { if (collider.gameObject.tag == "Player") { Health life = collider.GetComponent <Health>(); life.TakeDamage(damage, m_ProjectileBase.owner); } // damage if (areaOfDamage) { // area damage areaOfDamage.InflictDamageInArea(damage, point, hittableLayers, k_TriggerInteraction, m_ProjectileBase.owner); } else { // point damage Damageable damageable = collider.GetComponent <Damageable>(); if (damageable) { damageable.InflictDamage(damage, false, m_ProjectileBase.owner); } } // impact vfx if (impactVFX) { GameObject impactVFXInstance = Instantiate(impactVFX, point + (normal * impactVFXSpawnOffset), Quaternion.LookRotation(normal)); if (impactVFXLifetime > 0) { Destroy(impactVFXInstance.gameObject, impactVFXLifetime); } } // impact sfx if (impactSFXClip) { AudioUtility.CreateSFX(impactSFXClip, point, AudioUtility.AudioGroups.Impact, 1f, 3f); } // Self Destruct Destroy(this.gameObject); }
void OnHit(Vector3 point, Vector3 normal, Collider collider) //ヒット時(ポイントの向き、大きさ, コライダー) { // damage if (areaOfDamage) { // area damage areaOfDamage.InflictDamageInArea(damage, point, hittableLayers, k_TriggerInteraction, m_ProjectileBase.owner); } else { //ポイントダメージ Damageable damageable = collider.GetComponent <Damageable>(); //ダメージ ダメージ = コライダー.コンポーネントを取得<破損> if (damageable) { damageable.InflictDamage(damage, false, m_ProjectileBase.owner); //ダメージ ダメージを与える(ダメージ,false,m_ProjectileBase. オーナー) } } // impact vfx if (impactVFX) { GameObject impactVFXInstance = Instantiate(impactVFX, point + (normal * impactVFXSpawnOffset), Quaternion.LookRotation(normal)); if (impactVFXLifetime > 0) { Destroy(impactVFXInstance.gameObject, impactVFXLifetime); } } // impact sfx if (impactSFXClip) { AudioUtility.CreateSFX(impactSFXClip, point, AudioUtility.AudioGroups.Impact, 1f, 3f); } // Self Destruct Destroy(this.gameObject); }
void OnHit(Vector3 point, Vector3 normal, Collider collider) { // damage if (AreaOfDamage) { // area damage AreaOfDamage.InflictDamageInArea(Damage, point, HittableLayers, k_TriggerInteraction, m_ProjectileBase.Owner); } else { // point damage Damageable damageable = collider.GetComponent <Damageable>(); if (damageable) { damageable.InflictDamage(Damage, false, m_ProjectileBase.Owner); } } // impact vfx if (ImpactVfx) { GameObject impactVfxInstance = Instantiate(ImpactVfx, point + (normal * ImpactVfxSpawnOffset), Quaternion.LookRotation(normal)); if (ImpactVfxLifetime > 0) { Destroy(impactVfxInstance.gameObject, ImpactVfxLifetime); } } // impact sfx if (ImpactSfxClip) { AudioUtility.CreateSFX(ImpactSfxClip, point, AudioUtility.AudioGroups.Impact, 1f, 3f); } // Self Destruct Destroy(this.gameObject); }