public void collidedWith(Collider2D collider) { //if (gameObject.GetComponent<Rigidbody>().velocity.x > 0) //if we are throwing to the right //{ // //The x-extents of our player's collider is 0.62, so we subtract one more than that to ensure the collider will not overlap with the obstacle // transform.position = new Vector3(collider.bounds.min.x - 0.63f, transform.position.y, transform.position.z); //} //else //{ // //The x-extents of our player's collider is 0.62, so we subtract one more than that to ensure the collider will not overlap with the obstacle // transform.position = new Vector3(collider.bounds.max.x + 0.63f, transform.position.y, transform.position.z); //} spawningAttack.SetCollider(collider); spawningAttack.collided = true; if (batonOnHitClip != null) { playerAudioSource.volume = SoundManager.Instance.PlayerBatonOnHitVolume; SoundManager.Instance.PlayWithRandomizedPitch(playerAudioSource, batonOnHitClip); } if (collider.tag != "Obstacle") { Hurtbox hurtbox = collider.GetComponent <Hurtbox>(); hurtbox.ApplyAttack(damage); } }
public void collidedWith(Collider2D collider) { Hurtbox hurtbox = collider.GetComponent <Hurtbox>(); if (whipHitSound != null) { playerAudioSource.volume = SoundManager.Instance.PlayerWhipOnHitVolume; SoundManager.Instance.PlayWithRandomizedPitch(playerAudioSource, whipHitSound); } Instantiate(whipEffectPrefab, collider.transform); hurtbox.ApplyAttack(damage); }
public void collidedWith(Collider2D collider) { if (collider.tag != "Obstacle" && collider.tag != "Platform") { Hurtbox hurtbox = collider.GetComponent <Hurtbox>(); hurtbox.ApplyAttack(damage); } if (projectileOnHitClip != null) { droneAudioSource.volume = SoundManager.Instance.DroneProjectileOnHitVolume; SoundManager.Instance.PlayWithRandomizedPitch(droneAudioSource, projectileOnHitClip); } thisProjectile.velocity = Vector2.zero; hitbox.EndCheckCollisions(); //We don't want to continue collision detecting for hits once the particle has hit an obstacle and is playing the destroy animation animator.Play(destroyAnimationClipName); }
public void collidedWith(Collider2D collider) { Hurtbox hurtbox = collider.GetComponent <Hurtbox>(); hurtbox.ApplyAttack(damage); }