private void OnHit(PlayerHitVolume hitVolume, GameObject hittingGameObject) { currentShots = -maxCharge; if (dischargePrefab != null) { GameObject dischargeEffect = Instantiate(dischargePrefab, transform.position, transform.rotation); dischargeEffect.transform.localScale *= 0.33f; } }
void Start() { currentShots = maxCharge; PlayerHitVolume playerHitVolume = GetComponent <PlayerHitVolume>(); if (playerHitVolume != null) { playerHitVolume.OnHit += OnHit; } }
private void OnHit(PlayerHitVolume hitVolume, GameObject hittingGameObject) { if (hitVolume.GetComponent <PistolControl>() != null) { currentHits += damagePointsPerHitOnPistol; } if (hitVolume.GetComponent <Camera>() != null) { currentHits += damagePointsPerHitOnHead; } }
private void OnTriggerEnter(Collider other) { if (IsValidCollisionTarget(other)) { PlayerHitVolume playerHitVolume = other.GetComponent <PlayerHitVolume>(); if (playerHitVolume != null) { playerHitVolume.Hit(gameObject); } if (other.GetComponent <PistolControl>() != null) { Vector3 direction = transform.TransformDirection(Vector3.forward); Vector3 impactPoint = other.ClosestPoint(transform.position); Vector3 normal = (transform.position - impactPoint).normalized; Vector3 newDirection = Vector3.Reflect(direction, normal); transform.rotation *= Quaternion.FromToRotation(direction, newDirection); } else { Disappear(); } } }