using System; using System.Collections; using System.Collections.Generic; using UnityEngine; namespace Bausatz { public class Bullet : MonoBehaviour { public AudioClip shootSound; public AudioClip hitSound; private AudioSource _audio; private VRShoot _shoot; private void Awake() { _audio = GetComponent<AudioSource>(); } private void Start() { _audio.PlayOneShot(shootSound); } public void SetShoot(VRShoot shoot) { _shoot = shoot; } private void OnTriggerEnter(Collider other) { if (!other.CompareTag("Target")) return; if (!(Camera.main is null)) AudioSource.PlayClipAtPoint(hitSound, Camera.main.transform.position); _audio.PlayOneShot(hitSound); _shoot.Hit(); var target = other.GetComponent<Target>(); if (target != null) target.Hit(); Destroy(gameObject); } } }