void OnContact() { Debug.Log("[yellow]Contact Start"); CompCollider col = GetComponent <CompCollider>(); GameObject collided_obj = col.GetCollidedObject(); Vector3 point = col.GetContactPoint(); Vector3 normal = col.GetContactNormal(); // DAMAGE --- Debug.Log("[error] Collided"); if (collided_obj != null && destroyed == false) { /* PLAY AUDIO */ //GetComponent<CompAudio>().PlayEvent("TheonImpact"); //Lock transform to avoid trespassing more than one collider rb.LockTransform(); Debug.Log("[yellow] OnContact"); Debug.Log("[yellow]" + collided_obj.GetName()); } if (destroyed == false) { Destroy(gameObject); destroyed = true; } }
void OnContact() { col = GetComponent <CompCollider>(); GameObject obj = col.GetCollidedObject(); if (obj != null) { if (enemy_collision && obj.CompareTag("Enemy") && sword_enemy_particle != null) { col = GetComponent <CompCollider>(); Vector3 point = col.GetContactPoint(); col = GetComponent <CompCollider>(); Vector3 normal = col.GetContactNormal(); ShieldBlock_Action shield_block = obj.GetComponent <ShieldBlock_Action>(); if (shield_block != null) { if (shield_block.IsBlocking() == true) { return; } } sword_enemy_particle.GetComponent <Transform>().SetUpVector(normal); point = point + normal * 2; sword_enemy_particle.GetComponent <Transform>().SetPosition(point); enemy_particle = sword_enemy_particle.GetComponent <CompParticleSystem>(); enemy_particle.ActivateEmission(true); if (sword_enemy_particle2 != null) { enemy_particle = sword_enemy_particle2.GetComponent <CompParticleSystem>(); enemy_particle.ActivateEmission(true); } if (sword_enemy_particle3 != null) { enemy_particle = sword_enemy_particle3.GetComponent <CompParticleSystem>(); enemy_particle.ActivateEmission(true); } if (sword_enemy_particle4 != null) { enemy_particle = sword_enemy_particle4.GetComponent <CompParticleSystem>(); enemy_particle.ActivateEmission(true); } //Iterate all childs, they have a ParticleSystem too //int childs = sword_enemy_particle.ChildCount(); //for (int i = 0; i < childs; i++) //{ // sword_enemy_particle.GetChildByIndex(i).GetComponent<CompParticleSystem>().ActivateEmission(true); //} //Disable Enemy Collisions EnableEnemyCollision(false); } } }
void OnContact() { CompCollider col = GetComponent <CompCollider>(); GameObject collided_obj = col.GetCollidedObject(); Vector3 point = col.GetContactPoint(); Vector3 normal = col.GetContactNormal(); // DAMAGE --- if (collided_obj != null && destroyed == false) { /* PLAY AUDIO */ GetComponent <CompAudio>().PlayEvent("TheonImpact"); //Lock transform to avoid trespassing more than one collider rb.LockTransform(); // Check the specific enemy in front of you and apply dmg or call object OnContact EnemiesManager enemy_manager = GetLinkedObject("player_enemies_manager").GetComponent <EnemiesManager>(); if (enemy_manager.IsEnemy(collided_obj)) { enemy_manager.ApplyDamage(collided_obj, damage, Enemy_BT.ENEMY_GET_DAMAGE_TYPE.ARROW); if (arrow_blood_particles != null) { arrow_blood_particles.GetComponent <Transform>().SetUpVector(normal); arrow_blood_particles.GetComponent <Transform>().SetPosition(point + normal * 2); CompParticleSystem arrow_particles_script = arrow_blood_particles.GetComponent <CompParticleSystem>(); arrow_particles_script.ActivateEmission(true); } } else { CompCollider obj_col = collided_obj.GetComponent <CompCollider>(); if (obj_col != null) { obj_col.CallOnContact(); } if (arrow_sparks_particles != null) { arrow_sparks_particles.GetComponent <Transform>().SetUpVector(normal); arrow_sparks_particles.GetComponent <Transform>().SetPosition(point + normal * 2); CompParticleSystem wall_particles_script = arrow_sparks_particles.GetComponent <CompParticleSystem>(); wall_particles_script.ActivateEmission(true); } } } if (destroyed == false) { Destroy(gameObject); destroyed = true; } }
void OnContact() { col = GetComponent <CompCollider>(); GameObject obj = col.GetCollidedObject(); if (obj != null) { if (obj.CompareTag("enemy")) { col = GetComponent <CompCollider>(); Vector3 point = col.GetContactPoint(); col = GetComponent <CompCollider>(); Vector3 normal = col.GetContactNormal(); enemy_particle_obj.GetComponent <Transform>().SetUpVector(normal); enemy_particle_obj.GetComponent <Transform>().SetPosition(point); enemy_particle = enemy_particle_obj.GetComponent <CompParticleSystem>(); enemy_particle.ActivateEmission(true); } else if (obj.CompareTag("obstacle")) { col = GetComponent <CompCollider>(); Vector3 point = col.GetContactPoint(); col = GetComponent <CompCollider>(); Vector3 normal = col.GetContactNormal(); wall_particle_obj.GetComponent <Transform>().SetUpVector(normal); wall_particle_obj.GetComponent <Transform>().SetPosition(point); wall_particle = wall_particle_obj.GetComponent <CompParticleSystem>(); wall_particle.ActivateEmission(true); } } }
void OnContact() { CompCollider col = GetComponent <CompCollider>(); if (fireball_particles != null) { Vector3 point = col.GetContactPoint(); Vector3 normal = col.GetContactNormal(); fireball_particles.GetComponent <Transform>().SetUpVector(normal); point = point + normal * 4; fireball_particles.GetComponent <Transform>().SetPosition(point); CompParticleSystem fireball_particles_script = fireball_particles.GetComponent <CompParticleSystem>(); fireball_particles_script.ActivateEmission(true); if (fireball_particles2 != null) { fireball_particles_script = fireball_particles2.GetComponent <CompParticleSystem>(); fireball_particles_script.ActivateEmission(true); } if (fireball_particles3 != null) { fireball_particles_script = fireball_particles3.GetComponent <CompParticleSystem>(); fireball_particles_script.ActivateEmission(true); } if (fireball_particles4 != null) { fireball_particles_script = fireball_particles4.GetComponent <CompParticleSystem>(); fireball_particles_script.ActivateEmission(true); } } GameObject collided_obj = GetComponent <CompCollider>().GetCollidedObject(); GetComponent <CompAudio>().PlayEvent("DaenerysFireballImpact"); // DAMAGE --- if (collided_obj != null) { // Check the specific enemy in front of you and apply dmg or call object OnContact EnemiesManager enemy_manager = GetLinkedObject("player_enemies_manager").GetComponent <EnemiesManager>(); if (!destroyed) { if (enemy_manager.IsEnemy(collided_obj)) { enemy_manager.ApplyDamage(collided_obj, damage, Enemy_BT.ENEMY_GET_DAMAGE_TYPE.FIREBALL); } else { destroyed = true; Debug.Log("Destroy 1", Department.GENERAL); Destroy(gameObject); return; } } } if (fireball && destroyed == false) { col.CollisionActive(false); Debug.Log("Destroy 2", Department.GENERAL); Destroy(gameObject); destroyed = true; return; } }